/* mod-resources styles. Class prefix rs-. Colors come from the shared CSS variables. The only literals are white text on the
   green and red status fills (as the shared .btn-good and .btn-danger do) and the print palette at the end.
   Pages: approvals, discipline, SOP library, reports, audit log. */

.rs-page { min-width: 0; }
.rs-h3 { font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.rs-pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.rs-note { margin: -2px 0 10px; }
.rs-comment { margin-top: 2px; white-space: pre-wrap; overflow-wrap: anywhere; font-weight: 400; }
.rs-detail { gap: 18px; }
.rs-doclist { margin: 0; padding-left: 18px; }
.rs-list { min-width: 0; }
/* A table here is as wide as its content needs and no wider: the shared table styles let text wrap before anything scrolls. A name, a link, or a typed note
   (.rs-wrap) breaks anywhere, so one long word wraps inside its cell instead of stretching the table. Words from the division's own lists keep whole words. */
.rs-wrap { overflow-wrap: anywhere; }
.rs-list .table td { overflow-wrap: break-word; }
.rs-count-wrap { padding: 10px 20px; }
.rs-foot { margin: 12px 0 0; }

/* A table cell that opens a record. It is a real button so the keyboard can reach it. */
.rs-rowbtn {
  background: none; border: 0; padding: 0; margin: 0; font: inherit; font-weight: 600; color: var(--text); text-align: left; cursor: pointer;
  text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; overflow-wrap: anywhere; max-width: 100%;
}
.rs-rowbtn:hover { text-decoration-color: var(--gold); }

/* Where a table is too narrow for its columns (a phone, a tablet standing up, or a narrow window with the menu beside it) the rows of the table become
   cards, as in Recruit Management: the first cell is the title and every other cell reads "label, value". Nothing is hidden behind a sideways scroll.
   The widest table here (the audit log) needs about 650px, and the card has the window less the menu, the page margins, and a scrollbar: so cards at
   700px and below, and in the 901 to 980px band where the menu takes 264px of it. A cell with no value (a dash) is left out. Printing keeps the table. */
@media screen and (max-width: 700px), screen and (min-width: 901px) and (max-width: 980px) {
  .table.rs-cards, .table.rs-cards tbody, .table.rs-cards tr, .table.rs-cards td { display: block; width: 100%; }
  .table.rs-cards thead { display: none; }
  .table.rs-cards tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .table.rs-cards tbody tr:last-child { border-bottom: 0; }
  .table.rs-cards td, .table.rs-cards td:first-child, .table.rs-cards td:last-child { display: flex; align-items: baseline; gap: 12px; min-width: 0; padding: 4px 0; border: 0; }
  .table.rs-cards td::before {
    content: attr(data-label); flex: none; width: 112px; color: var(--muted); font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.04em;
  }
  .table.rs-cards td:first-child::before { display: none; }
  .table.rs-cards td:first-child { margin-bottom: 4px; padding-bottom: 8px; border-bottom: 1px dashed var(--line); font-size: 15px; }
  .table.rs-cards td.rs-none { display: none; }
  .table.rs-cards td > * { min-width: 0; }
  .table.rs-cards td.num { text-align: left; }
  .table.rs-cards .pill { white-space: normal; }
  .table.rs-cards td.nowrap { white-space: normal; }
  /* a link or button in a card line is a target of its own: at least 24px tall, and a line apart from the next */
  .table.rs-cards td a, .table.rs-cards td .rs-rowbtn { display: inline-block; padding: 3px 0; }
}

/* Approval tabs: the shared segmented control wraps into a grid on small screens */
.rs-seg { max-width: 100%; }
@media (max-width: 640px) {
  .rs-seg { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .rs-seg button { border-right: 0; border-bottom: 1px solid var(--line); white-space: normal; }
  .rs-seg button:nth-child(odd) { border-right: 1px solid var(--line); }
  .rs-seg button:nth-last-child(-n+2) { border-bottom: 0; }
  /* touch targets: the tabs and the small buttons are at least 40px tall on a phone, and a link that stands alone on its line is at least 24px */
  .rs-seg button, .rs-months button { min-height: 44px; }
  .rs-page .btn-sm { min-height: 40px; }
  .rs-page .grid.kpis .kpi-sub a, .rs-detail .kv a { display: inline-block; padding: 3px 0; }
}

/* Four-step approval workflow */
.rs-flow { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.rs-step { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 12px; padding: 0 0 16px; position: relative; }
.rs-step:last-child { padding-bottom: 0; }
.rs-step::before { content: ''; position: absolute; left: 14px; top: 32px; bottom: 2px; width: 2px; background: var(--line); }
.rs-step:last-child::before { display: none; }
.rs-step.is-done::before { background: var(--fill); }
.rs-dot {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700;
  background: var(--surface); border: 3px solid var(--line); color: var(--muted); position: relative; z-index: 1;
}
.rs-dot svg { width: 14px; height: 14px; }
.rs-step-title { font-weight: 600; }
.rs-step-note { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.rs-step.is-done .rs-dot { background: var(--fill); border-color: var(--fill); color: var(--done-fg); }
.rs-step.is-current .rs-dot { background: var(--gold); border-color: var(--fill); color: var(--navy); }
.rs-step.is-current > div:last-child { background: var(--surface-2); border-radius: 8px; padding: 6px 10px; margin-top: -4px; }
.rs-step.is-current .rs-step-title { font-weight: 700; }
.rs-step.is-current .rs-step-note { color: var(--text); font-weight: 600; }
.rs-step.is-good .rs-dot { background: var(--good); border-color: var(--good); color: #fff; }
.rs-step.is-bad .rs-dot { background: var(--bad); border-color: var(--bad); color: #fff; }
.rs-step.is-warn .rs-dot { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); }
.rs-step.is-skip .rs-dot { border-style: dashed; }
.rs-step.is-skip .rs-step-title, .rs-step.is-pending .rs-step-title { color: var(--muted); }

/* ---------- SOP library ---------- */
.rs-sop { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
.rs-sop-nav { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.rs-reader { min-width: 0; }
.rs-search { position: relative; margin-bottom: 12px; }
.rs-search > svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.rs-search .input { padding-left: 38px; padding-right: 42px; }
.rs-search input[type="search"]::-webkit-search-cancel-button { display: none; } /* the page has its own Clear search button */
.rs-clear {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%); display: inline-grid; place-items: center; width: 32px; height: 32px;
  padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer;
}
.rs-clear:hover { background: var(--hover); color: var(--text); }
.rs-clear[hidden] { display: none; }
/* While a word is typed the categories step aside, so the results sit directly under the search box */
.rs-find.is-searching .rs-cats, .rs-find.is-searching .rs-catsel { display: none; }
.rs-find.is-searching .rs-search { margin-bottom: 0; }
.rs-cats { display: flex; flex-direction: column; gap: 2px; }
.rs-cat {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; padding: 8px 12px;
  border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--text); text-align: left; cursor: pointer; font-weight: 600; font-size: 14px;
}
.rs-cat:hover { background: var(--hover); }
.rs-cat[aria-current="true"] { background: var(--btn-dark); color: var(--btn-dark-fg); }
.rs-cat .rs-n { min-width: 24px; text-align: center; padding: 0 8px; border-radius: 999px; font-size: 12px; background: var(--surface-2); color: var(--muted); }
.rs-cat[aria-current="true"] .rs-n { background: var(--gold); color: var(--navy); }
.rs-catsel { display: none; }
.rs-docs-list { list-style: none; margin: 0; padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.rs-doc {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; padding: 10px 12px;
  border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--text); text-align: left; cursor: pointer;
}
.rs-doc:hover { background: var(--hover); }
.rs-doc[aria-current="true"] { background: var(--surface-2); border-color: var(--line); }
.rs-doc-title { font-weight: 600; overflow-wrap: anywhere; }
.rs-doc-meta, .rs-snip { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.rs-reader .card-head { flex-wrap: wrap; }
/* a title or a version note with one long word wraps inside the card instead of pushing the page sideways */
.rs-reader .card-head h2 { min-width: 0; overflow-wrap: anywhere; }
.rs-reader .card-body, .rs-doc-view { min-width: 0; }
.rs-docmeta { margin-bottom: 18px; }
.rs-doc-body { max-width: 74ch; overflow-wrap: anywhere; }
.rs-doc-body p { margin: 0 0 14px; line-height: 1.65; white-space: pre-line; }
.rs-doc-body ul { margin: 0 0 14px; padding-left: 22px; line-height: 1.65; }
.rs-versions { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); min-width: 0; }
.rs-vlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.rs-vlist li { display: flex; gap: 12px; align-items: flex-start; min-width: 0; }
.rs-vlist li > div, .rs-vtext { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.rs-vbtn { flex: none; margin-left: auto; }
.rs-printtitle, .rs-printhead { display: none; }
@media (max-width: 1100px) {
  .rs-sop { grid-template-columns: minmax(0, 1fr); }
  .rs-cats { display: none; }
  .rs-catsel { display: block; }
}

/* ---------- reports ---------- */
.rs-scope { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: -8px; }
.rs-bad { color: var(--bad-fg); }
/* The tiles of one row share three rows (label, number, line under it), so every number sits at the same height even when one label wraps onto
   two lines. The gap between tile rows is a margin, because a subgrid would otherwise add the page's row gap inside each tile. */
.rs-page .grid.kpis { row-gap: 0; margin-bottom: -20px; }
.rs-page .grid.kpis > .kpi { display: grid; grid-row: span 3; grid-template-rows: subgrid; row-gap: 0; align-content: start; margin-bottom: 20px; }
.rs-page .grid.kpis .kpi-sub { margin-top: 4px; }
/* six tiles are two rows of three, not four and two */
@media (min-width: 641px) { .rs-page .grid.kpis.rs-kpis-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  /* on a phone the tiles are two across, so eight of them are four short rows and not eight tall ones */
  .rs-page .grid.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 12px; margin-bottom: -12px; }
  .rs-page .grid.kpis > .kpi { padding: 14px; margin-bottom: 12px; }
  .rs-page .grid.kpis .kpi-value { font-size: 30px; }
}
/* Phase completion rates (five bars) sits beside Training evaluation results (nine), so the two keep their own heights instead of the short card being
   stretched into a block of empty space. */
.rs-charts { align-items: start; }
.rs-chart { display: flex; flex-direction: column; gap: 12px; }
.rs-chart-sub { margin: 0; }
.rs-bars .hbar { grid-template-columns: minmax(100px, 190px) minmax(40px, 1fr) auto; }
.rs-bars .hbar > span:first-child { overflow-wrap: anywhere; }
.rs-bars .hbar .val { white-space: nowrap; }
/* a value of zero draws no bar (the shared stub is for values above zero, which the script gives a thin sliver) */
.rs-bars .hbar .fill { min-width: 0; }
@media (max-width: 640px) {
  /* the label and the value share a line and the bar has the full width under them, so a bar is wide enough to compare */
  .rs-bars .hbar { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'label val' 'track track'; gap: 4px 12px; padding: 8px 0; }
  .rs-bars .hbar > span:first-child { grid-area: label; }
  .rs-bars .hbar .val { grid-area: val; }
  .rs-bars .hbar .track { grid-area: track; }
}
.rs-stack { height: 30px; border-radius: 15px; }
.rs-stack span { display: grid; place-items: center; font-size: 12px; font-weight: 700; border-right: 2px solid var(--surface); }
.rs-stack span:last-child { border-right: 0; }
.rs-c-grad { background: var(--good); color: #fff; }
.rs-c-train { background: var(--gold); color: var(--navy); }
.rs-c-term { background: var(--bad); color: #fff; }
.rs-c-wd { background: var(--muted); color: var(--bg); }
.rs-cols .bar { flex: none; }
.rs-cols .col span { font-size: 12px; }
/* the export buttons share a grid, so none is left stranded at the end of a row */
.rs-export { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.rs-export .btn { width: 100%; }
.rs-prog { display: flex; align-items: center; gap: 10px; min-width: 140px; }
.rs-prog .progress { flex: 1; }
.rs-pills { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
@media (max-width: 1100px) { .rs-prog { min-width: 0; flex: 1; } }

/* Supervisor monthly report */
.rs-duties { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 2px; }
.rs-duties li { padding: 6px 0; }
.rs-form { max-width: 720px; }
.rs-hist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.rs-hist li { padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.rs-hist-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.rs-hist p { margin: 0; }
.rs-hist p + p { margin-top: 6px; }
.rs-months { max-width: 100%; align-self: flex-start; }
.rs-months button { white-space: normal; }
@media (max-width: 640px) {
  .rs-months { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .rs-months button { border-right: 0; }
  .rs-months button:first-child { border-right: 1px solid var(--line); }
}

/* ---------- filter bars (discipline and audit) ---------- */
/* The selects share the row evenly (as in Recruit Management) instead of each taking the width of its longest option. */
.rs-page .toolbar .search { flex: 2 1 240px; min-width: 0; }
.rs-page .toolbar .select { flex: 1 1 150px; width: auto; min-width: 0; }
@media (max-width: 1100px) { .rs-page .toolbar .search { flex: 1 1 100%; } } /* the search has a row of its own, and the selects share the next one evenly */
/* From and To are one group that never splits across rows, and the download sits at the far end. */
.rs-dates { display: flex; flex-wrap: nowrap; align-items: center; gap: 12px; }
.rs-date { display: inline-flex; align-items: center; gap: 8px; }
.rs-date .input { width: 156px; min-width: 0; }
.rs-csv { margin-left: auto; }
@media (max-width: 640px) {
  /* on a phone every control is the full width of the bar, and From and To sit side by side with their labels above */
  .rs-page .toolbar { gap: 10px; }
  .rs-page .toolbar > .search, .rs-page .toolbar > .select, .rs-page .toolbar > .rs-dates, .rs-page .toolbar > .rs-csv { flex: 1 1 100%; width: 100%; margin-left: 0; }
  .rs-dates { gap: 10px; }
  .rs-date { flex: 1 1 0; min-width: 0; flex-direction: column; align-items: stretch; gap: 4px; }
  .rs-date .input { width: 100%; }
  .rs-page .toolbar .select { min-height: 44px; }
  .rs-page .toolbar .btn { min-height: 44px; }
}

/* ---------- audit log ---------- */
.rs-audit .table td { vertical-align: top; }
/* a usual surname and a usual value (Unassigned, Awaiting review) keep to whole words; a very long word still wraps inside these widths */
.rs-audit .table td:nth-child(2) { min-width: 100px; }
.rs-audit .table td:nth-child(5), .rs-audit .table td:nth-child(6) { min-width: 88px; }
/* the pager sits above and below the table */
.rs-pagerwrap { border-top: 1px solid var(--line); padding: 12px 20px; }
.rs-pagerwrap.rs-pagertop { border-top: 0; border-bottom: 1px solid var(--line); padding: 10px 20px; }
.rs-pager { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- print: SOP documents and reports ---------- */
@media print {
  /* A dark theme still prints dark text on white paper. */
  :root[data-theme="dark"] .rs-page {
    --text: #000; --muted: #333; --surface: #fff; --surface-2: #eee; --hover: #f4f4f4; --line: #aaa; --fill: #222; --on-fill: #fff; --bg: #fff;
    --good: #1F5A38; --good-fg: #1F5A38; --good-bg: #DCEFE3; --bad: #8F2A20; --bad-fg: #8F2A20; --bad-bg: #F6DDD9;
    --warn: #6B4F08; --warn-bg: #F7E8C4; --info: #1E3A5F; --info-bg: #DCE4F0; --btn-dark: #0F1B2D; --btn-dark-fg: #F4F1EA; --field-bg: #fff; --field-line: #888;
  }
  .rs-printtitle, .rs-printhead { display: block; font-size: 13px; margin-bottom: 10px; }
  .rs-printhead { border-bottom: 2px solid #000; padding-bottom: 6px; }
  .rs-sop { display: block; }
  .rs-sop-nav, .rs-export-card, .rs-monthly, .rs-pager, .rs-pagerwrap, .rs-actions, .rs-sop-page .page-head, .rs-sop-page .notice { display: none !important; }
  .rs-reader .card { border: 0; box-shadow: none; }
  /* the printed table keeps a date on one line (the shared print rule lets every cell wrap, which put "Nov 14, 2026" on three) */
  .rs-list .table td.nowrap { white-space: nowrap; }
  .rs-doc-body { max-width: none; }
  .rs-stack, .rs-stack span, .legend .sw, .hbar .fill, .hbar .track, .cols .bar, .rs-dot, .pill, .progress, .progress-fill { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
