/* =====================================================================
   SHARED FORM RENDERER (.fx-) — copied verbatim into the STG app. Uses only the shared tokens & .input/.select/.textarea.
   ===================================================================== */
.fx { display: flex; flex-direction: column; gap: 18px; }
.fx-head { margin-bottom: 2px; }
.fx-title { font-family: var(--font-display); font-size: var(--fs-2xl); line-height: 1.15; color: var(--ink); margin: 0 0 6px; }
.fx-desc { font-size: var(--fs-md); }
.fx-section { padding: 6px 0 0; border-top: 1px solid var(--line-2); margin-top: 4px; }
.fx > .fx-section:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.fx-sec-title { font-family: var(--font-display); font-size: var(--fs-xl); line-height: 1.2; color: var(--ink); margin: 10px 0 4px; }
/* section text: plain text (escaped) up to 20,000 chars — blank-line paragraphs & "• " bullets kept via pre-line */
.fx-sec-text { white-space: pre-line; overflow-wrap: anywhere; font-size: var(--fs-md); line-height: 1.65; color: var(--text-2); max-width: 70ch; margin: 2px 0 0; }
.fx-section.no-title { border-top: 0; padding-top: 0; }
.fx-section.no-title .fx-sec-text { margin-top: 0; }
@media print { .fx-sec-text { color: #000; font-size: 11pt; line-height: 1.5; max-width: none; } }
.fx-field { display: block; min-width: 0; scroll-margin: 90px; }
.fx-label { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; font-size: var(--fs-md); font-weight: 750; color: var(--text); margin: 0 2px 7px; line-height: 1.3; }
.fx-label .ico { color: var(--muted); }
.fx-req { color: var(--coral-strong); font-style: normal; font-weight: 800; margin-left: 1px; }
.fx-opt { font-style: normal; font-weight: 600; font-size: var(--fs-xs); color: var(--faint); }
.fx-help { font-size: var(--fs-xs); color: var(--muted); margin: -3px 2px 8px; line-height: 1.45; }
.fx-sublabel { display: block; font-size: var(--fs-sm); font-weight: 700; color: var(--text-2); margin: 12px 2px 6px; }
.fx-err { display: flex; align-items: center; gap: 6px; color: var(--coral-strong); font-size: var(--fs-sm); font-weight: 700; margin: 7px 2px 0; }
.fx-err::before { content: '!'; display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--coral-strong); color: #fff; font-size: 11px; font-weight: 900; flex: none; }
:root[data-theme="dark"] .fx-err::before { background: var(--coral-fill); }
.fx-field.is-invalid .input, .fx-field.is-invalid .select, .fx-field.is-invalid .textarea,
.fx-field.is-invalid .fx-sig-pad, .fx-field.is-invalid .fx-filebox { border-color: var(--coral-strong); box-shadow: 0 0 0 4px var(--coral-soft); }
.fx-field.is-invalid .fx-choice span { border-color: var(--coral-strong); }
.fx .textarea { min-height: 120px; }
.fx .fx-dt { max-width: 240px; }
.fx .input[type="number"] { max-width: 240px; }

/* choice buttons (radio = one, checkboxes = many) */
.fx-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.fx-choice { position: relative; display: inline-flex; cursor: pointer; min-width: 0; }
.fx-choice input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.fx-choice span { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 10px 16px; border-radius: var(--r-input); border: 1.5px solid var(--line-2);
  background: var(--surface); color: var(--text-2); font-weight: 700; font-size: var(--fs-sm); line-height: 1.25; transition: background .15s, border-color .15s, color .15s; overflow-wrap: anywhere; }
.fx-choice input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; }
:root[data-theme="dark"] .fx-choice input:checked + span { background: var(--teal); border-color: var(--teal); color: #0F1838; }
.fx-choice input:focus-visible + span { box-shadow: 0 0 0 4px var(--teal-soft); border-color: var(--teal); }
.fx-tick { display: none; }
.fx-choices.is-multi .fx-choice span { padding-left: 12px; }
.fx-choices.is-multi .fx-choice span::before { content: ''; width: 16px; height: 16px; border-radius: 5px; border: 1.5px solid var(--line-2); flex: none; }
.fx-choices.is-multi .fx-choice input:checked + span::before { display: none; }
.fx-choices.is-multi .fx-choice input:checked + span .fx-tick { display: inline-block; }
@media (max-width: 520px) { .fx-choices.is-multi, .fx-choices:has(.fx-choice:nth-child(4)) { flex-direction: column; } .fx-choices.is-multi .fx-choice span, .fx-choices:has(.fx-choice:nth-child(4)) .fx-choice span { width: 100%; } }

/* files */
.fx-filebox { border: 1.5px dashed var(--line-2); border-radius: var(--r-input); padding: 12px; background: var(--surface-2); }
.fx-file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.fx-file-list { display: flex; flex-direction: column; gap: 8px; }
.fx-file-list:not(:empty) { margin-bottom: 10px; }
.fx-file { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); min-width: 0; }
.fx-thumb { flex: none; width: 48px; height: 48px; border-radius: 9px; overflow: hidden; background: var(--surface-3); display: grid; place-items: center; color: var(--muted); }
.fx-thumb img { width: 100%; height: 100%; object-fit: cover; }
.fx-file-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.fx-file-main b { font-size: var(--fs-sm); color: var(--text); }
.fx-file-main small { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.fx-file-hint { margin: 8px 2px 0; }
.fx-file-add[hidden] { display: none; }

/* signature */
.fx-sig-pad { position: relative; height: 180px; border-radius: var(--r-input); border: 1.5px solid var(--line-2); background: #FFFFFF; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.fx-sig-pad canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; display: block; }
.fx-sig-ph { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); text-align: center; color: #8A90A8; font-weight: 700; font-size: var(--fs-md); pointer-events: none; display: flex; align-items: center; justify-content: center; gap: 6px; }
.fx-sig-line { position: absolute; left: 22px; right: 22px; bottom: 38px; border-bottom: 1.5px solid #D5D8E5; pointer-events: none; }
.fx-sig-pad.has-ink .fx-sig-ph { display: none; }
.fx-sig-pad.is-drawing { border-color: var(--teal); box-shadow: 0 0 0 4px var(--teal-soft); }
.fx-sig-bar { display: flex; justify-content: flex-end; margin-top: 8px; }

/* read-only */
.fx-field.is-ro { padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.fx-field.is-ro:last-child { border-bottom: 0; padding-bottom: 0; }
.fx-field.is-ro .fx-label { font-size: var(--fs-sm); color: var(--muted); font-weight: 700; margin-bottom: 4px; }
.fx-value { font-size: var(--fs-md); color: var(--text); font-weight: 600; overflow-wrap: anywhere; }
.fx-pre { white-space: pre-wrap; font-weight: 500; line-height: 1.55; }
.fx-none { color: var(--faint); font-weight: 600; font-style: italic; }
.fx-empty { display: flex; align-items: center; gap: 6px; justify-content: center; padding: 18px 0; }
.fx-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.fx-pill { display: inline-flex; padding: 5px 11px; border-radius: var(--r-pill); background: var(--surface-3); color: var(--text); font-size: var(--fs-sm); font-weight: 700; }
.fx-ro-files { display: flex; flex-wrap: wrap; gap: 10px; }
.fx-ro-file { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 8px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text); font-size: var(--fs-sm); font-weight: 700; text-decoration: none; }
.fx-ro-file.is-img { flex-direction: column; align-items: stretch; padding: 6px; width: 140px; }
.fx-ro-file.is-img img { width: 100%; height: 100px; object-fit: cover; border-radius: 8px; background: var(--surface-3); }
.fx-ro-sig { display: inline-flex; flex-direction: column; gap: 6px; max-width: 100%; }
.fx-ro-sig img { width: 320px; max-width: 100%; height: auto; border-radius: 12px; border: 1px solid var(--line-2); background: #FFFFFF; }
.fx-ro-sig small { font-size: var(--fs-sm); color: var(--muted); font-weight: 600; }
.fx-ro-sig small b { color: var(--text); }
.fx-nogym { display: flex; align-items: center; gap: 6px; margin: 0 2px; }
/* ===================== END SHARED RENDERER ===================== */

/* =====================================================================
   PORTAL FORM SCREENS (.fm-)
   ===================================================================== */
.fm { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.fm > .card { margin: 0; }
.fm-head { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-items: center; padding: 18px; }
.fm-ico { width: 48px; height: 48px; border-radius: 14px; background: var(--teal-soft); color: var(--teal-strong); display: grid; place-items: center; grid-row: span 1; }
.fm-head-main { min-width: 0; }
.fm-title { font-family: var(--font-display); font-size: var(--fs-2xl); line-height: 1.15; color: var(--ink); margin: 0; overflow-wrap: anywhere; }
.fm-cat { display: block; margin-top: 3px; font-size: var(--fs-xs); font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.fm-desc, .fm-until, .fm-who, .fm-meta { grid-column: 1 / -1; }
.fm-desc { margin-top: 8px; font-size: var(--fs-md); }
.fm-desc > :first-child { margin-top: 0; } .fm-desc > :last-child { margin-bottom: 0; }
.fm-until, .fm-who { display: flex; align-items: center; gap: 6px; margin: 4px 0 0; font-size: var(--fs-sm); color: var(--muted); font-weight: 600; }
.fm-who b { color: var(--text); }
.fm-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.fm-body { padding: 20px 18px; }
.fm-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.fm-submit { min-width: 200px; }
.fm-note { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 0 0 10px; font-size: var(--fs-xs); color: var(--faint); font-weight: 600; text-align: center; }
@media (max-width: 600px) {
  .fm-head { padding: 16px; }
  .fm-title { font-size: var(--fs-xl); }
  .fm-body { padding: 18px 14px; }
  .fm-actions .btn { flex: 1; }
  .fm-submit { min-width: 0; }
}
.fm-banner { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-group); font-size: var(--fs-sm); line-height: 1.4; }
.fm-banner > .ico { flex: none; margin-top: 1px; }
.fm-banner b { display: block; font-weight: 800; }
.fm-banner span { display: block; font-weight: 600; opacity: .92; }
.fm-banner.violet { background: var(--violet-soft); color: var(--violet); }
.fm-banner.blue { background: var(--blue-soft); color: var(--blue); }
.fm-done, .fm-closed { text-align: center; padding: 34px 22px 26px; display: flex; flex-direction: column; align-items: center; }
.fm-done h2, .fm-closed h2 { font-family: var(--font-display); font-size: var(--fs-2xl); color: var(--ink); margin: 14px 0 6px; }
.fm-done-ico { width: 72px; height: 72px; border-radius: 22px; background: var(--teal-soft); color: var(--teal-strong); display: grid; place-items: center; }
.fm-done-ico.is-muted { background: var(--surface-3); color: var(--muted); }
.fm-done-msg, .fm-closed p { margin: 0 auto; max-width: 460px; font-size: var(--fs-md); color: var(--text-2); line-height: 1.55; white-space: pre-line; }
.fm-done-sub { margin: 10px 0 0; font-size: var(--fs-xs); color: var(--faint); font-weight: 700; }
.fm-done-acts { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 20px; }
.fm-hp { position: absolute !important; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden; }
.fm-divider { height: 1px; background: var(--line-2); margin: 18px 0; }
.fm-pub-host { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.fm-pub { min-height: 100%; padding: calc(var(--sat) + 22px) 16px calc(var(--sab) + 24px); display: flex; flex-direction: column; align-items: stretch; }
.fm-pub-top { text-align: center; }
.fm-pub-top .auth-logo { height: 60px; }
.fm-pub-body { width: 100%; }
.fm-pub .auth-foot { text-align: center; }
.fm-pub .fm-body .fx-field + .fx-field { margin-top: 16px; }

/* lists (My Forms, profile & HR sections, staff home) */
.fm-my { max-width: 820px; margin: 0 auto; }
.fm-list .row-sub { white-space: nowrap; }
.fm-list .pill { flex: none; }
.fm-empty { display: flex; align-items: center; gap: 10px; padding: 14px 16px; color: var(--muted); font-weight: 600; margin: 0; }
.fm-empty .ico { color: var(--teal-strong); }
.fm-asg.is-overdue .row-title { color: var(--coral-strong); }
.fm-groups { display: flex; flex-direction: column; gap: 14px; }
.fm-group > h3 { margin: 0 2px 8px; font-size: var(--fs-xs); font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.fm-sec-note { margin: 8px 2px 0; }

/* Employee Central: Forms to Complete */
.sh-forms { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; }
.sh-forms > .list { border: 0; border-radius: 0; }
.sh-forms .sh-more { border-top: 1px solid var(--line); }
.sh-count.is-hot { background: var(--coral-strong); }
.fx-field.is-ro:has(+ .fx-section) { border-bottom: 0; padding-bottom: 0; }

/* Notify Me sheet */
.fm-notify { display: flex; flex-direction: column; gap: 10px; }
.fm-notify-intro { margin: 0 2px 4px; color: var(--text-2); font-weight: 600; }
.fm-check { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r-group); border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; }
.fm-check input { width: 20px; height: 20px; accent-color: var(--ink); flex: none; }
.fm-check span { display: flex; flex-direction: column; }
.fm-check b { color: var(--text); font-size: var(--fs-md); }
.fm-check small { color: var(--muted); font-weight: 600; font-size: var(--fs-xs); }

/* Public form: no app chrome (it is a standalone link) */
.page[data-route="f"] .pg-head { display: none; }
.fx .input + .fx-help, .fm-body .input + .fx-help { margin: 6px 2px 0; }
[data-team-forms] { margin-top: 22px; }
.fx-field[hidden], .fx[hidden] { display: none !important; }
