/* public/assets/css/s52-calendar-planner.css
   KHMER HRMS — Calendar: Events Planner (Day/Week/Month/Year) + Public Holiday Notice
   Scoped with the cp- prefix. Colours come from theme variables only (light/dark safe)
   except the printed "paper", which is always white/black so it prints correctly. */

/* ── Tab bar ───────────────────────────────────────────────────── */
.cp-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 16px; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; width: fit-content; max-width: 100%; }
.cp-tab { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 9px; color: var(--text-muted); text-decoration: none; font-weight: 600; font-size: 0.9rem; }
.cp-tab svg { width: 16px; height: 16px; }
.cp-tab:hover { background: color-mix(in srgb, var(--primary) 8%, transparent); color: var(--text); }
.cp-tab.is-active { background: var(--primary); color: #fff; }

/* ── Toolbar ───────────────────────────────────────────────────── */
.cp-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.cp-seg { display: inline-flex; background: color-mix(in srgb, var(--text-muted) 12%, transparent); border-radius: 10px; padding: 3px; }
.cp-seg a { padding: 7px 18px; border-radius: 8px; text-decoration: none; color: var(--text-muted); font-weight: 600; font-size: 0.88rem; }
.cp-seg a.is-active { background: var(--surface); color: var(--primary); box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.cp-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cp-jump { display: inline-flex; gap: 6px; align-items: center; margin-left: 6px; }
.cp-jump .form-control { height: 34px; padding: 0 10px; }
.cp-hint { margin: 0; font-size: 0.82rem; display: inline-flex; gap: 6px; align-items: center; }
.cp-hint svg { width: 14px; height: 14px; }

/* ── Sheet (planner body) ──────────────────────────────────────── */
.cp-sheet { margin-bottom: 20px; }
.cp-sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 2px solid var(--primary); }
.cp-company { font-size: 0.8rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); }
.cp-title { margin: 2px 0 0; font-size: 1.5rem; }
.cp-sub { margin-top: 4px; font-size: 0.82rem; color: var(--text-muted); }
.cp-sheet-kind { padding: 4px 12px; border-radius: 999px; background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); font-weight: 700; font-size: 0.78rem; text-transform: uppercase; letter-spacing: .05em; }
.cp-empty { padding: 24px 0; text-align: center; }
.cp-dash { color: var(--text-muted); opacity: .5; text-align: center; display: block; padding-top: 8px; }

.cp-chip { display: block; font-size: 0.74rem; line-height: 1.3; padding: 3px 7px; margin-top: 3px; border-radius: 6px; text-decoration: none; color: var(--cc); background: color-mix(in srgb, var(--cc) 12%, transparent); border-left: 3px solid var(--cc); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-chip b { font-variant-numeric: tabular-nums; }
.cp-chip.is-holiday { background: color-mix(in srgb, var(--cc) 20%, transparent); font-weight: 700; }
.cp-more { display: block; font-size: 0.72rem; color: var(--primary); text-decoration: none; margin-top: 3px; }

/* Day */
.cp-day { display: grid; grid-template-columns: 220px 1fr; gap: 24px; }
.cp-day-badge { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 20px 12px; border-radius: 16px; background: linear-gradient(160deg, color-mix(in srgb, var(--primary) 14%, transparent), color-mix(in srgb, var(--primary) 4%, transparent)); border: 1px solid var(--border); align-self: start; }
.cp-day-badge.is-today { border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 30%, transparent); }
.cp-day-dow { font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: .06em; font-size: 0.85rem; }
.cp-day-num { font-size: 4.2rem; font-weight: 800; line-height: 1.05; }
.cp-day-mon { font-weight: 600; }
.cp-day-lunar { margin-top: 8px; font-size: 0.78rem; color: var(--text-muted); }
.cp-h { margin: 14px 0 8px; font-size: 0.78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.cp-h:first-child { margin-top: 0; }
.cp-row { display: flex; gap: 14px; align-items: flex-start; padding: 12px 14px; margin-bottom: 8px; border-radius: 10px; border: 1px solid var(--border); border-left: 5px solid var(--cc); background: color-mix(in srgb, var(--cc) 6%, var(--surface)); text-decoration: none; color: inherit; }
.cp-row:hover { background: color-mix(in srgb, var(--cc) 12%, var(--surface)); }
.cp-row-time { min-width: 96px; font-weight: 700; color: var(--cc); font-variant-numeric: tabular-nums; }
.cp-row-main { display: flex; flex-direction: column; gap: 2px; }
.cp-row-main small { color: var(--text-muted); }

/* Week */
.cp-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.cp-wcol { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); min-height: 260px; display: flex; flex-direction: column; }
.cp-wcol.is-today { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.cp-whead { display: flex; flex-direction: column; align-items: center; padding: 10px 6px; background: color-mix(in srgb, var(--primary) 7%, transparent); text-decoration: none; color: inherit; border-bottom: 1px solid var(--border); }
.cp-wcol.is-today .cp-whead { background: var(--primary); color: #fff; }
.cp-wdow { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; }
.cp-wnum { font-size: 1.6rem; font-weight: 800; line-height: 1.1; }
.cp-wlunar { font-size: 0.64rem; opacity: .75; text-align: center; margin-top: 2px; }
.cp-wbody { padding: 6px; flex: 1; }
.cp-wbody .cp-chip { white-space: normal; }

/* Month */
.cp-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cp-mdow { text-align: center; font-weight: 700; font-size: 0.78rem; color: var(--text-muted); padding: 6px 0; text-transform: uppercase; }
.cp-mcell { min-height: 118px; border: 1px solid var(--border); border-radius: 8px; padding: 5px; background: var(--surface); overflow: hidden; }
.cp-mcell.is-empty { border-color: transparent; background: transparent; }
.cp-mcell.is-sun .cp-mnum { color: #DC2626; }
.cp-mcell.is-hol { background: color-mix(in srgb, #DC2626 6%, var(--surface)); }
.cp-mcell.is-today { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.cp-mtop { display: flex; justify-content: space-between; align-items: baseline; gap: 4px; }
.cp-mnum { font-weight: 700; text-decoration: none; color: inherit; font-size: 0.92rem; }
.cp-mcell.is-today .cp-mnum { background: var(--primary); color: #fff; border-radius: 999px; padding: 0 7px; }
.cp-mlunar { font-size: 0.58rem; color: var(--text-muted); text-align: right; line-height: 1.2; }

/* Year */
.cp-year { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.cp-mini { border: 1px solid var(--border); border-radius: 12px; padding: 10px; background: var(--surface); }
.cp-mini-title { display: block; text-align: center; font-weight: 700; margin-bottom: 6px; text-decoration: none; color: var(--primary); }
.cp-mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.cp-mini-dow { font-size: 0.62rem; color: var(--text-muted); font-weight: 700; }
.cp-mini-day { font-size: 0.72rem; line-height: 22px; height: 22px; border-radius: 6px; text-decoration: none; color: inherit; position: relative; }
.cp-mini-day:hover { background: color-mix(in srgb, var(--primary) 14%, transparent); }
.cp-mini-day.is-sun { color: #DC2626; }
.cp-mini-day.has-ev { background: color-mix(in srgb, #2563EB 18%, transparent); font-weight: 700; }
.cp-mini-day.is-hol { background: #DC2626; color: #fff; font-weight: 700; }
.cp-mini-day.is-today { outline: 2px solid var(--primary); outline-offset: -1px; }

/* Legend + list */
.cp-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 0.78rem; color: var(--text-muted); }
.cp-legend i, .cp-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.cp-dot { border-radius: 50%; }
.cp-list-card h3 { margin-top: 0; }

/* ── Public Holiday Notice "paper" ─────────────────────────────── */
.cp-paper { background: #fff; color: #111; max-width: 900px; margin: 0 auto 24px; padding: 36px 44px 40px; border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 6px 28px rgba(0,0,0,.12); font-family: 'Battambang', 'NotoSansKhmer', 'Barlow', sans-serif; }
.cp-paper-head { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; margin-bottom: 18px; }
.cp-paper-logo { max-height: 64px; max-width: 200px; object-fit: contain; }
.cp-paper-name { font-size: 1.6rem; font-weight: 700; letter-spacing: .02em; }
.cp-paper-name-kh { font-family: 'Moul', 'Battambang', serif; font-size: 1rem; }
.cp-paper-addr { font-size: 0.78rem; color: #444; }
.cp-paper-title-kh { font-family: 'Moul', 'Battambang', serif; text-align: center; font-size: 1.15rem; font-weight: 400; line-height: 1.7; margin: 14px 0 2px; }
.cp-paper-title-en { text-align: center; font-size: 1.15rem; margin: 0 0 18px; }
.cp-paper-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.cp-paper-table th, .cp-paper-table td { border: 1px solid #333; padding: 7px 10px; vertical-align: middle; }
.cp-paper-table th { background: #f1f3f6; text-align: center; font-weight: 700; }
.cp-paper-table th span { display: block; }
.cp-paper-table .kh { font-family: 'Battambang', 'NotoSansKhmer', sans-serif; }
.cp-paper-table .en { font-size: 0.78rem; color: #333; }
.cp-paper-table tbody .kh { color: #111; }
.cp-paper-table .strong { font-weight: 700; }
.cp-paper-table .center { text-align: center; white-space: nowrap; }
.cp-paper-table .right { text-align: right; }
.cp-paper-table tfoot td { background: #f7f8fa; font-weight: 700; }
.cp-paper-table tbody tr { page-break-inside: avoid; }
.cp-sign { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin-top: 34px; font-size: 0.82rem; }
.cp-sign-label small { color: #555; }
.cp-sign-space { height: 70px; border-bottom: 1px dotted #666; margin-bottom: 8px; }
.cp-sign-name { font-weight: 700; min-height: 1.3em; }
.cp-sign-title { color: #333; min-height: 1.3em; }
[contenteditable][data-ph]:empty::before { content: attr(data-ph); color: #999; font-weight: 400; }
[contenteditable]:focus { outline: 1px dashed var(--primary); }

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 1100px) { .cp-year { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .cp-year { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cp-day { grid-template-columns: 1fr; }
  .cp-week { grid-template-columns: 1fr; }
  .cp-wcol { min-height: 0; }
  .cp-whead { flex-direction: row; gap: 10px; justify-content: flex-start; padding: 8px 12px; }
  .cp-mcell { min-height: 70px; }
  .cp-mlunar { display: none; }
  .cp-month .cp-chip span { display: none; }
  .cp-month .cp-chip { height: 8px; padding: 0; }
  .cp-month .cp-chip b { display: none; }
  .cp-paper { padding: 20px 14px; }
  .cp-sign { grid-template-columns: 1fr; }
}
@media (max-width: 520px) { .cp-year { grid-template-columns: 1fr; } }

/* ── Print ─────────────────────────────────────────────────────── */
@media print {
  .no-print, .sidebar, .top-bar, .hamburger, .cp-tabs, .cp-toolbar { display: none !important; }
  body, .main-content, .content, main { background: #fff !important; }
  .layout-shell, .main-wrap, .main-content { margin: 0 !important; padding: 0 !important; width: 100% !important; max-width: none !important; }
  .card { box-shadow: none !important; border: none !important; padding: 0 !important; background: #fff !important; color: #000 !important; }
  .cp-sheet, .cp-list-card { margin: 0 0 8mm; }
  .cp-sheet { page-break-inside: auto; }
  .cp-title { font-size: 1.3rem; }
  .cp-chip { white-space: normal; border: 1px solid color-mix(in srgb, var(--cc) 50%, #fff); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .cp-mcell { min-height: 24mm; }
  .cp-wcol { min-height: 120mm; }
  .cp-year { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .cp-mini { page-break-inside: avoid; }
  .cp-mini-day, .cp-mcell.is-hol, .cp-whead, .cp-sheet-kind, .cp-day-badge, .cp-row, .cp-paper-table th, .cp-paper-table tfoot td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .cp-list tr { page-break-inside: avoid; }
  .cp-paper { box-shadow: none; border: none; border-radius: 0; max-width: none; padding: 0; margin: 0; }
  [contenteditable][data-ph]:empty::before { content: ''; }
  a { color: inherit !important; }
}

/* ── Print shell fix (Calendar Planner / Holiday Notice) ───────────
   The on-screen shell rules `.sidebar.sidebar-hidden { display:flex !important }`,
   `.sidebar { position:fixed !important }` and `.main-wrap.sidebar-is-* { margin-left }`
   are MORE specific than the generic print rules above, so the fixed sidebar
   printed on every page and pushed/clipped the calendar. These selectors use
   `html body` + the same state classes so they always win in print. */
@page { size: A4 portrait; margin: 10mm; }
@media print {
  html body .sidebar,
  html body .sidebar.sidebar-hidden,
  html body .sidebar.mobile-open,
  html body .sidebar-overlay,
  html body .top-bar,
  html body .hamburger,
  html body .no-print,
  html body .toast-container,
  html body .swal2-container { display: none !important; visibility: hidden !important; }

  html body .layout-shell { display: block !important; }
  html body .main-wrap,
  html body .main-wrap.sidebar-is-open,
  html body .main-wrap.sidebar-is-collapsed {
    margin: 0 !important; padding: 0 !important; width: 100% !important; max-width: none !important; min-height: 0 !important;
  }
  html body .main-content {
    padding: 0 !important; margin: 0 !important; min-height: 0 !important; width: 100% !important; max-width: none !important;
  }
  html body .cp-year { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; gap: 6px !important; }
  html body .cp-mini { break-inside: avoid; page-break-inside: avoid; padding: 6px; }
  html body .cp-mini-day { line-height: 18px; height: 18px; font-size: 0.66rem; }
  html body .cp-sheet { overflow: visible !important; }
  html body .cp-sign { break-inside: avoid; page-break-inside: avoid; margin-top: 18px; }
  html body .cp-sign-col { break-inside: avoid; page-break-inside: avoid; }
  html body .cp-paper-table tfoot { break-inside: avoid; }
}

/* ── Print: hide floating tooltip + fit full year on ONE page ────── */
@media print {
  html body #hrms-unified-tooltip,
  html body [role="tooltip"],
  html body .hrms-tooltip-target::before,
  html body .hrms-tooltip-target::after,
  html body .tip::before,
  html body .tip::after { display: none !important; visibility: hidden !important; opacity: 0 !important; }

  html body .cp-view-year { break-inside: avoid; page-break-inside: avoid; overflow: hidden !important; }
  html body .cp-view-year .cp-sheet-head { margin-bottom: 4mm; padding-bottom: 2mm; }
  html body .cp-view-year .cp-title { font-size: 1.1rem; }
  html body .cp-view-year .cp-year { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; gap: 4mm !important; }
  html body .cp-view-year .cp-mini { padding: 3mm; border-radius: 6px; }
  html body .cp-view-year .cp-mini-title { margin-bottom: 2mm; font-size: 0.85rem; }
  html body .cp-view-year .cp-mini-grid { gap: 1px; }
  html body .cp-view-year .cp-mini-day { height: 5.2mm; line-height: 5.2mm; font-size: 0.62rem; }
  html body .cp-view-year .cp-mini-dow { font-size: 0.55rem; }
  html body .cp-view-year .cp-legend { margin-top: 3mm; padding-top: 2mm; font-size: 0.65rem; break-inside: avoid; }
}

/* ── Event name UI polish (chips + day rows) ─────────────────────── */
.cp-chip { display: flex; align-items: center; gap: 5px; padding: 4px 8px; margin-top: 4px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--cc) 25%, transparent); border-left-width: 1px; background: color-mix(in srgb, var(--cc) 10%, var(--surface)); color: color-mix(in srgb, var(--cc) 82%, #000); font-weight: 600; transition: transform .12s ease, box-shadow .12s ease; }
.cp-chip:hover { transform: translateY(-1px); box-shadow: 0 3px 10px color-mix(in srgb, var(--cc) 25%, transparent); }
.cp-chip-dot { flex: 0 0 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--cc); }
.cp-chip b { flex: 0 0 auto; padding: 0 5px; border-radius: 999px; background: var(--cc); color: #fff; font-size: 0.64rem; line-height: 1.5; }
.cp-chip span { overflow: hidden; text-overflow: ellipsis; }
.cp-chip.is-holiday { background: color-mix(in srgb, var(--cc) 16%, var(--surface)); }
.cp-wbody .cp-chip { align-items: flex-start; border-radius: 10px; }
.cp-wbody .cp-chip-dot { margin-top: 5px; }
.cp-row { align-items: center; padding: 12px 16px; border-radius: 14px; border: 1px solid color-mix(in srgb, var(--cc) 22%, var(--border)); border-left: 5px solid var(--cc); box-shadow: 0 1px 3px rgba(15,23,42,.06); transition: transform .12s ease, box-shadow .12s ease; }
.cp-row:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(15,23,42,.10); }
.cp-row-time { min-width: 0; padding: 4px 12px; border-radius: 999px; background: var(--cc); color: #fff; font-size: 0.78rem; white-space: nowrap; }
.cp-row-main b { font-size: 1rem; }
.cp-row-main small { font-size: 0.78rem; }
.cp-title { font-family: var(--font-kh), 'Battambang', 'NotoSansKhmer', sans-serif; font-weight: 800; }
.cp-sub { font-family: var(--font-kh), 'Battambang', 'NotoSansKhmer', sans-serif; }

/* ── Print: full year on ONE A4 sheet (landscape, 4 × 3 months) ──── */
@media print {
  html body .cp-chip, html body .cp-row-time, html body .cp-chip b, html body .cp-chip-dot { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  html body .cp-view-year { height: auto !important; margin: 0 !important; }
  html body .cp-view-year .cp-sheet-head { margin-bottom: 3mm; padding-bottom: 2mm; }
  html body .cp-view-year .cp-title { font-size: 1.15rem; margin: 0; }
  html body .cp-view-year .cp-sub { font-size: 0.7rem; margin-top: 1mm; }
  html body .cp-view-year .cp-year { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; gap: 3mm !important; }
  html body .cp-view-year .cp-mini { padding: 2mm 2.5mm; }
  html body .cp-view-year .cp-mini-title { margin-bottom: 1mm; font-size: 0.8rem; }
  html body .cp-view-year .cp-mini-day { height: 4.4mm; line-height: 4.4mm; font-size: 0.6rem; }
  html body .cp-view-year .cp-mini-dow { font-size: 0.5rem; }
  html body .cp-view-year .cp-legend { margin-top: 2mm; padding-top: 1.5mm; font-size: 0.6rem; }
}

/* ── Print list (date · event name · days) + print modes ─────────── */
.cp-print-mode { height: 38px; min-width: 230px; }
.cp-print-list { display: none; }

@media print {
  /* Screen preview keeps the full table; paper gets the compact list. */
  html body .cp-list-card .table-wrap { display: none !important; }
  html body .cp-list-card { margin: 0 !important; break-inside: auto; }
  html body .cp-list-card h3 { font-size: 0.85rem; margin: 0 0 1.5mm; }
  html body .cp-print-list { display: block !important; font-family: 'Battambang', 'NotoSansKhmer', 'Barlow', sans-serif; color: #111; }
  html body .cp-pl-head, html body .cp-pl-row, html body .cp-pl-total { display: grid; grid-template-columns: 1.15fr 1.6fr .55fr; gap: 3mm; padding: 1mm 2mm; align-items: center; }
  html body .cp-pl-head { background: #f1f3f6; border: 1px solid #333; font-weight: 700; font-size: 0.62rem; text-align: center; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  html body .cp-pl-row { border-bottom: 1px solid #bbb; font-size: 0.64rem; line-height: 1.25; break-inside: avoid; page-break-inside: avoid; }
  html body .cp-pl-row .kh, html body .cp-pl-row .en { display: block; }
  html body .cp-pl-row .en { font-size: 0.56rem; color: #444; }
  html body .cp-pl-row .cnt { text-align: center; white-space: nowrap; }
  html body .cp-pl-row .strong { font-weight: 700; }
  html body .cp-pl-total { border-top: 1.5px solid #333; font-size: 0.66rem; justify-content: space-between; grid-template-columns: 1fr auto; }

  /* Option 1 (default): everything on ONE portrait A4 sheet */
  html:not([data-print-mode="split"]) body .cp-view-year .cp-year { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; gap: 2.5mm !important; }
  html:not([data-print-mode="split"]) body .cp-view-year .cp-mini { padding: 1.5mm 2mm; }
  html:not([data-print-mode="split"]) body .cp-view-year .cp-mini-title { margin-bottom: .5mm; font-size: 0.75rem; }
  html:not([data-print-mode="split"]) body .cp-view-year .cp-mini-day { height: 4.1mm; line-height: 4.1mm; font-size: 0.58rem; }
  html:not([data-print-mode="split"]) body .cp-view-year .cp-sheet-head { margin-bottom: 2mm; padding-bottom: 1.5mm; }
  html:not([data-print-mode="split"]) body .cp-view-year ~ .cp-list-card { margin-top: 3mm !important; }
  html:not([data-print-mode="split"]) body .cp-view-year ~ .cp-list-card .cp-pl-body { column-count: 2; column-gap: 5mm; }
  html:not([data-print-mode="split"]) body .cp-view-year ~ .cp-list-card .cp-pl-row { grid-template-columns: 1.15fr 1.4fr .5fr; padding: .6mm 1mm; gap: 1.5mm; font-size: 0.58rem; }
  html:not([data-print-mode="split"]) body .cp-view-year ~ .cp-list-card .cp-pl-row .en { display: none; }
  html:not([data-print-mode="split"]) body .cp-view-year ~ .cp-list-card .cp-pl-head { display: none; }

  /* Option 2: calendar on its own landscape sheet, list on a new page */
  html[data-print-mode="split"] body .cp-view-year ~ .cp-list-card { break-before: page; page-break-before: always; margin-top: 0 !important; }
}

/* ── Tabs row: tabs on the left, Print control right beside them ──── */
.cp-tabs-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 0 0 16px; }
.cp-tabs-row .cp-tabs { margin: 0; }
.cp-print-ctl { display: inline-flex; align-items: center; gap: 8px; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.cp-print-pick { position: relative; display: inline-flex; align-items: center; gap: 8px; margin: 0; padding: 0 10px; height: 38px; border-radius: 9px; background: color-mix(in srgb, var(--text-muted) 10%, transparent); color: var(--text-muted); cursor: pointer; }
.cp-print-pick svg { width: 16px; height: 16px; flex: 0 0 auto; }
.cp-print-pick select { appearance: none; -webkit-appearance: none; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 0.86rem; font-weight: 600; padding: 0 20px 0 0; height: 100%; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 20 20' fill='none' stroke='%236b7280' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 8l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0 center; }
.cp-print-pick:focus-within { box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 35%, transparent); }
.cp-print-btn { display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 16px; border: 0; border-radius: 9px; background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 70%, #1e3a5f)); color: #fff; font: inherit; font-size: 0.88rem; font-weight: 700; cursor: pointer; box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 35%, transparent); transition: transform .12s ease, box-shadow .12s ease; }
.cp-print-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 14px color-mix(in srgb, var(--primary) 40%, transparent); }
.cp-print-btn svg { width: 16px; height: 16px; }
@media (max-width: 640px) { .cp-print-ctl { width: 100%; } .cp-print-pick { flex: 1; } .cp-print-pick select { width: 100%; } }

/* ── Jump-to-date: system picker (KH/EN) + Go button ─────────────── */
.cp-jump { gap: 8px; flex-wrap: nowrap; }
.cp-jump .cp-jump-picker { width: 190px; min-width: 150px; }
.cp-jump .btn { white-space: nowrap; min-width: 64px; height: 38px; padding: 0 16px; }

@media print {
  html body .cp-tabs-row, html body .cp-print-ctl { display: none !important; }
  /* @page margin is 0 on the year sheet (so the browser prints no header/footer
     = no page numbers); the safe margin is supplied as padding instead. */
  html[data-print-mode] body .main-content { padding: 8mm 10mm !important; }
  html[data-print-mode="split"] body .cp-view-year ~ .cp-list-card { padding-top: 10mm !important; }
}

/* ── Add-event button sits right after the tabs ──────────────────── */
.cp-add-btn { display: inline-flex; align-items: center; gap: 7px; height: 46px; padding: 0 18px; border-radius: 12px; background: var(--primary); color: #fff; font-weight: 700; font-size: 0.88rem; text-decoration: none; box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 35%, transparent); transition: transform .12s ease, box-shadow .12s ease; }
.cp-add-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 14px color-mix(in srgb, var(--primary) 40%, transparent); color: #fff; }
.cp-add-btn svg { width: 16px; height: 16px; }
.cp-tabs-row .cp-print-ctl { margin-left: auto; }
@media (max-width: 640px) { .cp-add-btn { width: 100%; justify-content: center; } .cp-tabs-row .cp-print-ctl { margin-left: 0; } }

/* ── Khmer font in the print-mode dropdown (closed state + option list) ── */
.cp-print-pick select,
.cp-print-pick select option,
.cp-print-pick select optgroup {
  font-family: var(--font-kh), 'Battambang', 'Noto Sans Khmer', 'NotoSansKhmer', 'Khmer OS Battambang', 'Khmer OS System', 'Leelawadee UI', 'Nirmala UI', system-ui, sans-serif;
}
.cp-print-pick select option { font-size: 0.9rem; color: #111; background: #fff; padding: 6px 10px; }
.cp-print-btn, .cp-add-btn { font-family: var(--font-kh), 'Battambang', 'Noto Sans Khmer', 'NotoSansKhmer', system-ui, sans-serif; }

/* ── Print control sits directly after "Add event" (no push to far right) ── */
.cp-tabs-row .cp-print-ctl { margin-left: 0; }
.cp-pp { position: relative; }
.cp-pp-trigger { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border: 0; border-radius: 9px; background: color-mix(in srgb, var(--text-muted) 10%, transparent); color: var(--text); font-weight: 600; font-size: 0.86rem; cursor: pointer; }
.cp-pp-trigger svg { width: 16px; height: 16px; flex: 0 0 auto; color: var(--text-muted); }
.cp-pp-trigger:focus-visible, .cp-pp-menu li:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.cp-pp-chev { transition: transform .15s ease; }
.cp-pp-trigger[aria-expanded="true"] .cp-pp-chev { transform: rotate(180deg); }
.cp-pp-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 120; min-width: 100%; width: max-content; max-width: 320px; margin: 0; padding: 6px; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(15,23,42,.16); }
.cp-pp-menu[hidden] { display: none; }
.cp-pp-menu li { padding: 9px 12px; border-radius: 8px; font-size: 0.88rem; line-height: 1.5; cursor: pointer; color: var(--text); }
.cp-pp-menu li:hover { background: color-mix(in srgb, var(--primary) 10%, transparent); }
.cp-pp-menu li.is-sel { background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); font-weight: 700; }
.cp-pp-trigger, .cp-pp-menu, .cp-pp-menu li { font-family: var(--font-kh), 'Battambang', 'Noto Sans Khmer', 'NotoSansKhmer', 'Khmer OS Battambang', 'Leelawadee UI', system-ui, sans-serif; }

/* ── Holiday Notice: manage + print icon buttons right after the tabs ── */
.cp-tab-actions { display: inline-flex; align-items: center; gap: 8px; }
.cp-icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 46px; height: 46px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; transition: transform .12s ease, box-shadow .12s ease, background .12s ease; }
.cp-icon-btn:hover { transform: translateY(-1px); background: color-mix(in srgb, var(--primary) 8%, var(--surface)); box-shadow: 0 6px 14px rgba(15,23,42,.12); }
.cp-icon-btn svg { width: 18px; height: 18px; }
.cp-icon-btn.is-primary { border-color: transparent; background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 70%, #1e3a5f)); color: #fff; box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 35%, transparent); }
.cp-icon-btn.is-primary:hover { background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 70%, #1e3a5f)); }
@media print { html body .cp-tab-actions { display: none !important; } }

/* ── Ordinal suffix (st/nd/rd/th): small + raised like formal documents ── */
sup.ord { font-size: 0.62em; line-height: 0; vertical-align: baseline; position: relative; top: -0.55em; margin-left: 0.04em; font-weight: inherit; letter-spacing: 0; }

/* ── Public Holiday Notice: always ONE A4 portrait page ──────────── */
@media print {
  html body .cp-paper { zoom: var(--cp-fit, 1); width: 100% !important; break-inside: avoid; page-break-inside: avoid; overflow: visible; }
  html body .cp-paper-head { margin-bottom: 3mm; gap: 1mm; }
  html body .cp-paper-logo { max-height: 14mm; max-width: 50mm; }
  html body .cp-paper-name { font-size: 1.2rem; line-height: 1.25; }
  html body .cp-paper-name-kh { font-size: 0.85rem; line-height: 1.5; }
  html body .cp-paper-addr { font-size: 0.64rem; line-height: 1.35; }
  html body .cp-paper-title-kh { font-size: 0.95rem; line-height: 1.55; margin: 3mm 0 0; }
  html body .cp-paper-title-en { font-size: 0.95rem; margin: 0 0 3mm; }
  html body .cp-paper-table { font-size: 0.72rem; }
  html body .cp-paper-table th, html body .cp-paper-table td { padding: 1.1mm 2mm; line-height: 1.3; }
  html body .cp-paper-table .en { font-size: 0.66rem; line-height: 1.25; }
  html body .cp-paper-table tr { break-inside: avoid; page-break-inside: avoid; }
  html body .cp-paper .cp-sign { margin-top: 6mm; font-size: 0.72rem; gap: 10mm; break-inside: avoid; page-break-inside: avoid; }
  html body .cp-paper .cp-sign-space { height: 15mm; margin-bottom: 2mm; }
  html body .cp-paper .cp-sign-name, html body .cp-paper .cp-sign-title { min-height: 1.1em; }
  html body .cp-paper { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Keep the total row + signatures glued to the table on the same sheet */
@media print {
  html body .cp-paper-table { break-after: avoid; page-break-after: avoid; }
  html body .cp-paper .cp-sign { break-before: avoid; page-break-before: avoid; }
}

/* ROOT CAUSE of the 2nd page: the A4 print viewport is ~700px wide, which matches the
   `@media (max-width: 860px)` mobile rule above that stacks .cp-sign into ONE column
   (3 tall blocks) — too tall for the space left under the table, so it jumped to page 2.
   Force the desktop 3-column signature row (and desktop paper spacing) for paper. */
@media print {
  html body .cp-paper .cp-sign { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
  html body .cp-paper { padding: 0 !important; }
}

/* Print: keep the "Name / Position" placeholders visible, but very faint (10%) so a
   signer can still see where to write while an empty form looks clean. */
@media print {
  html body [contenteditable][data-ph]:empty::before {
    content: attr(data-ph) !important;
    color: #000 !important;
    opacity: 0.1;
    font-weight: 400;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
}


/* ── Print: full grid lines on the events list + no table pager chrome ─── */
@media print {
  /* "Show [20]" · "Showing 1–17 of 17" · page buttons must never reach paper */
  html body .cp-list-card .table-footer,
  html body .cp-list-card .hrms-table-footer,
  html body .cp-list-card .table-top-controls,
  html body .cp-list-card .hrms-table-toolbar,
  html body .cp-list-card .per-page-control,
  html body .cp-list-card .table-showing-info,
  html body .cp-list-card .client-page-info,
  html body .cp-list-card .client-page-buttons,
  html body .cp-list-card .pagination,
  html body:has(.cp-list-card) .hrms-table-shell > .table-footer,
  html body:has(.cp-list-card) .hrms-table-shell > .hrms-table-footer,
  html body:has(.cp-list-card) .hrms-table-shell > .table-top-controls,
  html body:has(.cp-list-card) .hrms-table-shell > .hrms-table-toolbar { display: none !important; }

  /* Ruled table: outer frame + horizontal AND vertical lines */
  html body .cp-pl-head,
  html body .cp-pl-row { gap: 0 !important; padding: 0 !important; border: 1px solid #333 !important; border-top: 0 !important; }
  html body .cp-pl-head { border-top: 1px solid #333 !important; }
  html body .cp-pl-head > span,
  html body .cp-pl-row > span { padding: 1mm 2mm !important; border-left: 1px solid #333; align-self: stretch; display: flex; flex-direction: column; justify-content: center; }
  html body .cp-pl-head > span { align-items: center; }
  html body .cp-pl-head > span:first-child,
  html body .cp-pl-row > span:first-child { border-left: 0; }
  html:not([data-print-mode="split"]) body .cp-view-year ~ .cp-list-card .cp-pl-row { padding: 0 !important; gap: 0 !important; }
  html:not([data-print-mode="split"]) body .cp-view-year ~ .cp-list-card .cp-pl-row > span { padding: .6mm 1mm !important; }
}
