/* ============================================================================
 * Popay payroll simulator — "live payslip" redesign, styles.
 * Recreates the design-handoff prototype (Simulateur de paie) faithfully.
 * The payslip IS the form: every underlined value is edited in-document.
 *
 * The widget is a DUMB RENDERER — it paints whatever sections/lines/totals the
 * /api/payslip API returns (numbers come from the Oracle engine); no payroll
 * logic lives here. See payslip.js.
 *
 * Tokens are scoped to .pl-root using the documented Popay palette so the sheet
 * looks identical wherever it is embedded. Fonts inherit the site's display /
 * body fonts (Roboto) with a graceful fallback.
 * ========================================================================== */

.pl-root {
  /* Popay palette (design-handoff) */
  --blue: #009dc5;
  --blue-deep: #0070c0;
  --purple: #7d326d;
  --amber: #efa742;
  --p-text: #1d171a;
  --p-muted: #6c7075;
  --p-line: #e2e6ea;
  --p-line-soft: #eef1f3;
  --p-brand-lt: #e6f5fa;   /* hover tint */
  --p-brand-lt2: #f4f9fb;  /* faint band */
  --p-page: #f4f6f8;
  --font-head: var(--font-display, 'Roboto', system-ui, sans-serif);
  --font-product: var(--font-body, 'Roboto', system-ui, sans-serif);
  --font-mono: ui-monospace, 'SFMono-Regular', 'Roboto Mono', monospace;
  /* configurable accent (bar / table header / net band) */
  --pl-accent: var(--blue);

  font-family: var(--font-product);
  color: var(--p-text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 8px 0 24px;
}
.pl-root * { box-sizing: border-box; }

/* editable bare inputs */
.pl-nak {
  font-family: inherit; border: none; outline: none; background: transparent;
  padding: 0; margin: 0; color: inherit;
}

/* ---- toolbar --------------------------------------------------------------- */
.pl-toolbar {
  width: 100%; max-width: 860px; display: flex; align-items: center;
  justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.pl-tt { font-family: var(--font-head); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--blue); }
.pl-ts { font-size: 13px; color: var(--p-muted); }
.pl-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pl-lang { display: inline-flex; border: 1px solid var(--p-line); border-radius: 8px; overflow: hidden; background: #fff; }
.pl-seg { border: none; padding: 7px 12px; cursor: pointer; font-family: var(--font-head); font-size: 11.5px; font-weight: 600; background: #fff; color: var(--p-muted); }
.pl-seg.on { background: var(--blue); color: #fff; }
.pl-locpill { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border: 1px solid var(--p-line); border-radius: 999px; background: #fff; font-family: var(--font-head); font-size: 12px; font-weight: 600; color: var(--p-text); }
.pl-locpill .sq { width: 9px; height: 9px; border-radius: 2px; background: var(--blue); }
.pl-tbtn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border: 1px solid var(--p-line); border-radius: 7px; background: #fff; font-family: var(--font-head); font-size: 12px; font-weight: 600; color: var(--p-text); cursor: pointer; }
.pl-tbtn:hover { background: var(--p-brand-lt2); }
.pl-tbtn svg { width: 14px; height: 14px; }

/* ---- sheet ----------------------------------------------------------------- */
.pl-sheet {
  width: 100%; max-width: 860px; background: #fff; border: 1px solid var(--p-line);
  border-radius: 12px; box-shadow: 0 18px 50px rgba(15, 30, 45, .12); overflow: hidden; position: relative;
}
.pl-accent { height: 5px; background: var(--pl-accent); }

.pl-head { position: relative; padding: 26px 34px 22px; display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; border-bottom: 1px solid var(--p-line-soft); overflow: hidden; }
.pl-wave { position: absolute; top: -40px; right: -30px; width: 320px; opacity: .10; pointer-events: none; }
.pl-logo { height: 34px; display: block; margin-bottom: 12px; }
.pl-emp-name { font-family: var(--font-head); font-size: 13px; font-weight: 700; color: var(--p-text); }
.pl-emp-meta { font-size: 12px; line-height: 1.5; color: var(--p-muted); }
.pl-head-right { position: relative; text-align: right; }
.pl-badge { padding: 3px 9px; border-radius: 999px; background: var(--amber); color: #3a2a05; font-family: var(--font-head); font-size: 9.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.pl-title { font-family: var(--font-head); font-size: 22px; font-weight: 700; color: var(--p-text); line-height: 1.1; margin-top: 8px; }
.pl-period { margin-top: 6px; font-size: 12px; color: var(--p-muted); }
.pl-period input { font-family: var(--font-head); font-weight: 600; color: var(--blue); width: 110px; text-align: right; border-bottom: 1.5px dashed var(--blue); cursor: text; }

/* ---- identity strip -------------------------------------------------------- */
.pl-ident { display: grid; grid-template-columns: 1fr 1fr; background: var(--p-brand-lt2); border-bottom: 1px solid var(--p-line-soft); }
.pl-grp { padding: 15px 26px 18px 34px; display: flex; flex-direction: column; gap: 14px; }
.pl-grp.a { border-right: 1px solid var(--p-line); }
.pl-grp.b { padding: 15px 34px 18px 26px; }
.pl-grp-title { display: flex; align-items: center; gap: 7px; white-space: nowrap; font-family: var(--font-head); font-size: 9.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.pl-grp.a .pl-grp-title { color: var(--blue); }
.pl-grp.b .pl-grp-title { color: var(--purple); }
.pl-grp-title svg { width: 13px; height: 13px; flex: 0 0 auto; }
.pl-flabel { font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--p-muted); margin-bottom: 4px; }
.pl-frow { display: flex; gap: 26px; flex-wrap: wrap; }
.pl-edit-name { font-family: var(--font-head); font-size: 15px; font-weight: 600; color: var(--p-text); width: 100%; border-bottom: 1.5px dashed transparent; cursor: text; }
.pl-edit-name:hover { border-bottom-color: var(--blue); }
.pl-edit-sub { font-size: 12px; color: var(--p-muted); width: 100%; margin-top: 2px; border-bottom: 1.5px dashed transparent; cursor: text; }
.pl-edit-sub:hover { border-bottom-color: var(--blue); }
.pl-edit-mat { font-family: var(--font-mono); font-size: 13px; color: var(--p-text); width: 82px; border-bottom: 1.5px dashed transparent; cursor: text; }
.pl-edit-mat:hover { border-bottom-color: var(--purple); }

.pl-segset { display: inline-flex; border: 1px solid var(--p-line); border-radius: 8px; overflow: hidden; }
.pl-stepper { display: inline-flex; align-items: center; gap: 2px; border: 1px solid var(--p-line); border-radius: 7px; background: #fff; overflow: hidden; }
.pl-step-btn { border: none; background: none; width: 26px; height: 26px; font-size: 16px; color: var(--blue); cursor: pointer; line-height: 1; }
.pl-step-val { min-width: 34px; text-align: center; font-family: var(--font-head); font-size: 13px; font-weight: 600; }
.pl-step-val.wide { min-width: 56px; }
.pl-contract-note { font-size: 11px; color: var(--p-muted); line-height: 1.4; margin-top: 7px; }

/* ---- 5-column grid --------------------------------------------------------- */
.pl-grid { display: grid; grid-template-columns: 1fr 120px 78px 130px 130px; }
.pl-thead { padding: 11px 34px; background: var(--pl-accent); color: #fff; font-family: var(--font-head); font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.pl-thead > div + div { text-align: right; }
.pl-sec { padding: 9px 34px 4px; font-family: var(--font-head); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.pl-sec.gains { color: var(--blue); }
.pl-sec.ded { color: var(--purple); padding-top: 12px; }

.pl-row { align-items: center; padding: 9px 34px; border-bottom: 1px solid var(--p-line-soft); }
.pl-row .lbl { font-size: 13.5px; color: var(--p-text); }
.pl-row .base, .pl-row .rate { text-align: right; font-size: 13px; color: var(--p-muted); font-variant-numeric: tabular-nums; }
.pl-row .gain, .pl-row .ret { text-align: right; font-variant-numeric: tabular-nums; font-size: 14px; font-weight: 600; }
.pl-row .ret { color: var(--purple); }
.pl-dash { text-align: right; color: var(--p-muted); font-size: 13px; }
.pl-note { font-size: 10.5px; color: var(--p-muted); margin-top: 2px; }
.pl-slider { -webkit-appearance: none; appearance: none; background: transparent; flex: 1; height: 16px; }
.pl-slider::-webkit-slider-runnable-track { height: 4px; border-radius: 999px; background: #dbe7ea; }
.pl-slider::-moz-range-track { height: 4px; border-radius: 999px; background: #dbe7ea; }
.pl-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%; background: var(--blue); border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); cursor: pointer; }
.pl-slider::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--blue); border: 2px solid #fff; cursor: pointer; }
.pl-sliderwrap { display: flex; align-items: center; gap: 10px; margin-top: 6px; max-width: 230px; }

/* click-to-edit amount */
.pl-amt { display: inline-flex; align-items: center; gap: 5px; justify-content: flex-end; cursor: pointer; padding: 2px 5px; border-radius: 4px; border-bottom: 1.5px dashed var(--blue); }
.pl-amt:hover { background: var(--p-brand-lt); }
.pl-amt svg { width: 12px; height: 12px; opacity: .5; }
.pl-amt-editing { display: inline-flex; align-items: center; gap: 2px; justify-content: flex-end; border-bottom: 1.5px solid var(--blue); }
.pl-amt-editing .cur { color: var(--p-muted); font-weight: 400; }
.pl-amt-editing input { width: 78px; text-align: right; font-family: inherit; font-weight: 600; font-variant-numeric: tabular-nums; }

/* toggles (rep / cimr) */
.pl-lblrow { display: flex; align-items: center; gap: 12px; }
.pl-toggle { position: relative; width: 38px; height: 22px; border-radius: 999px; border: none; cursor: pointer; padding: 0; flex: 0 0 auto; background: #cdd6db; transition: background 180ms; }
.pl-toggle.on { background: var(--blue); }
.pl-knob { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left 180ms; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.pl-toggle.on .pl-knob { left: 19px; }
.pl-tlabel { font-size: 13.5px; color: var(--p-muted); }
.pl-tlabel.on { color: var(--p-text); }

/* custom rows */
.pl-remove { flex: 0 0 auto; width: 20px; height: 20px; border: none; border-radius: 5px; background: #f6e9ee; color: var(--purple); cursor: pointer; font-size: 15px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
.pl-rowlabel-edit { display: flex; align-items: center; gap: 9px; min-width: 0; }
.pl-clabel { font-size: 13.5px; color: var(--p-text); border-bottom: 1.5px dashed var(--p-line); min-width: 0; flex: 0 1 auto; }
.pl-clabel:hover { border-bottom-color: var(--blue); }
.pl-pill { border: none; cursor: pointer; padding: 2px 8px; border-radius: 999px; font-family: var(--font-head); font-size: 9.5px; font-weight: 700; letter-spacing: .04em; background: var(--p-brand-lt); color: var(--blue); flex: 0 0 auto; }
.pl-pill.exempt { background: #eef7ee; color: #3c7a3c; }
.pl-camt { display: inline-flex; align-items: center; gap: 2px; justify-content: flex-end; border-bottom: 1.5px solid var(--blue); }
.pl-camt.ded { border-bottom-color: var(--purple); }
.pl-camt .cur { color: var(--p-muted); font-weight: 400; }
.pl-camt input { width: 74px; text-align: right; font-family: inherit; font-weight: 600; font-variant-numeric: tabular-nums; }
.pl-camt.ded input { color: var(--purple); }

/* add pay element */
.pl-addwrap { position: relative; padding: 10px 34px 12px; }
.pl-add { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border: 1.5px dashed var(--pl-accent); border-radius: 8px; background: transparent; font-family: var(--font-head); font-size: 12.5px; font-weight: 600; color: var(--pl-accent); cursor: pointer; }
.pl-add svg { width: 15px; height: 15px; }
.pl-menu { position: absolute; top: 46px; left: 34px; z-index: 30; width: 340px; background: #fff; border: 1px solid var(--p-line); border-radius: 10px; box-shadow: 0 16px 40px rgba(15,30,45,.18); overflow: hidden; }
.pl-menu-sec { padding: 10px 14px 5px; font-family: var(--font-head); font-size: 9.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.pl-menu-sec.gains { color: var(--blue); }
.pl-menu-sec.ded { color: var(--purple); border-top: 1px solid var(--p-line-soft); }
.pl-menu-item { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 14px; border: none; background: none; cursor: pointer; text-align: left; font-family: var(--font-product); font-size: 13px; color: var(--p-text); }
.pl-menu-item:hover { background: var(--p-brand-lt); }
.pl-menu-item .tag { font-size: 10px; color: var(--p-muted); }

/* totals + net */
.pl-total { align-items: center; padding: 11px 34px; border-bottom: 1px solid var(--p-line); }
.pl-total.brut { background: var(--p-brand-lt2); }
.pl-total.ret { background: #faf4f8; }
.pl-total .lbl { font-family: var(--font-head); font-size: 13px; font-weight: 700; color: var(--p-text); }
.pl-total .val { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-head); font-size: 14.5px; font-weight: 700; }
.pl-total.brut .val { color: var(--p-text); }
.pl-total.ret .val { color: var(--purple); }
.pl-net { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 22px 34px; background: var(--pl-accent); }
.pl-net-lbl { font-family: var(--font-head); font-size: 16px; font-weight: 700; color: #fff; }
.pl-net-rate { font-size: 12px; color: rgba(255,255,255,.85); }
.pl-net-val { font-family: var(--font-head); font-size: 30px; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; line-height: 1; white-space: nowrap; }

/* annual footer */
.pl-annual { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--p-line); }
.pl-annual-item { padding: 16px 34px; }
.pl-annual-item.a { border-right: 1px solid var(--p-line-soft); }
.pl-annual-lbl { font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--p-muted); margin-bottom: 4px; }
.pl-annual-val { font-family: var(--font-head); font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pl-annual-val.brut { color: var(--p-text); }
.pl-annual-val.net { color: var(--blue); }
.pl-disclaimer { padding: 12px 34px; border-top: 1px solid var(--p-line-soft); font-size: 11px; color: var(--p-muted); line-height: 1.5; }

.pl-hint { width: 100%; max-width: 860px; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--p-muted); }
.pl-hint .dash { display: inline-block; width: 22px; border-bottom: 1.5px dashed var(--blue); }

.pl-loading { opacity: .55; transition: opacity 120ms; }
.pl-error { padding: 18px 34px; color: var(--purple); font-size: 13px; }

/* responsive */
@media (max-width: 720px) {
  .pl-grid { grid-template-columns: 1fr 88px 96px; }
  .pl-thead .base, .pl-row .base, .pl-row.hascols .rate { display: none; }
  .pl-ident { grid-template-columns: 1fr; }
  .pl-grp.a { border-right: none; border-bottom: 1px solid var(--p-line); }
}

/* print */
@media print {
  .pl-noprint { display: none !important; }
  .pl-root { padding: 0; }
  .pl-sheet { box-shadow: none !important; border: none !important; }
}
