/*
 * rm.css — the risk-management shell, over the safety platform's app.css (v0.50.0, Flagler edition).
 * NO TENANT COLOUR OR NAME IS WRITTEN HERE. [I20] Colours come from the custom properties app.css sets from /api/config.
 * Sizes are rem on screen and pt in print (FONT_UNIT).
 */

.rm-topbar { flex-wrap: wrap; gap: 0.5rem; }
.rm-home { color: inherit; text-decoration: none; }
.rm-nav { display: flex; gap: 0.25rem; padding: 0 max(1rem, calc((100% - 64rem) / 2 + 0.5rem)); border-bottom: 1px solid var(--line); background: var(--card); overflow-x: auto; }
.rm-nav a { padding: 0.75rem 0.9rem; color: var(--ink-soft); text-decoration: none; font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.rm-nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.rm-view { max-width: 64rem; margin: 0 auto; padding: 1rem 1.25rem 1.5rem; }
/* The footer sits in the same column as the page above it: the same width, the same side padding. */
#view-app > .foot { max-width: 64rem; margin: 0 auto; padding: 0 1.25rem 2rem; }
.rm-view:focus { outline: none; }
.rm-h { margin: 0.25rem 0 0.25rem; font-size: 1.4rem; line-height: 1.25; }
.rm-sub { margin: 0 0 1rem; color: var(--ink-soft); }

/* The suite: one card per app, one column on a phone, up to three on a desk. */
.rm-cards { display: grid; gap: 0.9rem; grid-template-columns: 1fr; }
@media (min-width: 40rem) { .rm-cards { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 64rem) { .rm-cards { grid-template-columns: repeat(3, 1fr); } }
.rm-card { background: var(--card); border: 1px solid var(--line); border-radius: 0.75rem; padding: 1rem; display: flex; flex-direction: column; gap: 0.6rem; min-width: 0; }
.rm-card__title { margin: 0; font-size: 1.1rem; line-height: 1.3; overflow-wrap: anywhere; }
.rm-card__state { margin: 0; font-size: 0.9rem; color: var(--ink-soft); }
.rm-card__roles { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0; padding: 0; list-style: none; }
.rm-card__act { margin-top: auto; }
.rm-card__act a.btn--primary { color: #fff; }
.rm-card__act a.btn--quiet { color: var(--ink); }
.rm-card__act .btn { width: 100%; justify-content: center; text-align: center; text-decoration: none; display: inline-flex; min-height: 2.75rem; align-items: center; }
.rm-state { display: inline-block; padding: 0.1rem 0.55rem; border-radius: 999px; font-size: 0.8rem; font-weight: 700; border: 1px solid var(--line); }
.rm-state--moved { background: var(--ok-bg); border-color: var(--ok-line); }
.rm-state--current { background: var(--info-bg); border-color: var(--info-line); }
.rm-state--unlinked { background: var(--warn-bg); border-color: var(--warn-line); }

/* Settings */
.rm-app { background: var(--card); border: 1px solid var(--line); border-radius: 0.75rem; padding: 1rem; margin-bottom: 0.9rem; }
.rm-app h3 { margin: 0 0 0.5rem; font-size: 1.05rem; }
.rm-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin: 0.5rem 0; }
.rm-row input[type="text"] { flex: 1 1 14rem; min-width: 0; min-height: 2.5rem; padding: 0.4rem 0.6rem; font: inherit; border: 1px solid var(--line); border-radius: 0.4rem; }
.rm-jobs { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.rm-jobs th, .rm-jobs td { text-align: left; padding: 0.35rem 0.4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.rm-jobs select { min-height: 2.25rem; font: inherit; }
.rm-scroll { overflow-x: auto; }

/* The signature pad: a dashed box the same shape as the apps' own (220px high), pen colour from the page, never a tenant's. */
.rm-pad { position: relative; border: 1px dashed var(--ink-soft); border-radius: 0.5rem; background: #fff; height: 220px; margin-top: 0.5rem; touch-action: none; user-select: none; -webkit-user-select: none; }
.rm-pad canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; display: block; }
.rm-pad__hint { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--ink-soft); pointer-events: none; font-size: 0.95rem; padding: 0 1rem; text-align: center; }
.rm-pad__line { position: absolute; left: 6%; right: 6%; bottom: 28%; border-bottom: 1px solid var(--line); pointer-events: none; }
.rm-pad--locked { opacity: 0.6; }
.rm-pad__bar { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-top: 0.5rem; }
.rm-out { margin: 0.75rem 0 0; overflow-wrap: anywhere; font-size: 0.9rem; color: var(--ink-soft); }
.rm-out img { display: block; max-width: 100%; height: auto; border: 1px solid var(--line); background: #fff; margin-top: 0.4rem; }

@media print { .rm-nav, .topbar__right, .rm-pad__bar { display: none !important; } }

/* A phone: each job is a small block (its name, then when it runs and its mode) so the Mode select is never pushed off the card. */
@media (max-width: 40rem) {
  .rm-jobs thead { position: absolute; left: -9999px; }
  .rm-jobs, .rm-jobs tbody { display: block; }
  .rm-jobs tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; column-gap: 0.5rem; border-bottom: 1px solid var(--line); padding: 0.4rem 0; }
  .rm-jobs td { border: 0; padding: 0.15rem 0.4rem; min-width: 0; overflow-wrap: anywhere; }
  .rm-jobs td:first-child { grid-column: 1 / -1; font-weight: 600; }
  .rm-jobs select { width: 100%; min-width: 0; box-sizing: border-box; }
  .rm-jobs td:nth-child(2) { color: var(--ink-soft); }
}

/* ---------------------------------------------------------------- the Apps home (v0.56.0)
 * One spacing scale: 0.25 / 0.5 / 0.75 / 1 / 1.5 / 2.5 rem. Colours are the Appearance colours (--primary, --accent, --ink, --line, --card). */
.rmh { display: block; }
.rmh-head { margin: 0 0 1.5rem; }
.rmh-head .rm-h { font-size: 1.6rem; margin: 0 0 0.25rem; }
.rmh-head .rm-sub { margin: 0; max-width: 42rem; }
.rmh-sec { margin: 0 0 2.5rem; }
.rmh-title { margin: 0 0 0.25rem; font-size: 1.15rem; line-height: 1.3; }
.rmh-hint { margin: 0 0 1rem; color: var(--ink-soft); font-size: 0.92rem; }

.rmh-apps { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 40rem) { .rmh-apps { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 64rem) { .rmh-apps { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.rmh-card { display: flex; flex-direction: column; gap: 0.75rem; min-width: 0; padding: 1.25rem; background: var(--card); border: 1px solid var(--line); border-radius: 0.75rem; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.04); }
.rmh-card:hover { box-shadow: 0 2px 4px rgba(16, 24, 40, 0.08), 0 4px 10px rgba(16, 24, 40, 0.06); }
.rmh-card__top { display: flex; align-items: center; gap: 0.75rem; }
.rmh-card__title { margin: 0; font-size: 1.05rem; line-height: 1.3; overflow-wrap: anywhere; }
.rmh-card__line { margin: 0; color: var(--ink-soft); font-size: 0.92rem; line-height: 1.45; }
.rmh-card__chip { margin: 0; }
.rmh-card__act { margin-top: auto; padding-top: 0.25rem; }
.rmh-card__act .btn { width: 100%; justify-content: center; text-align: center; text-decoration: none; display: inline-flex; min-height: 2.75rem; align-items: center; }
.rmh-card__act a.btn--primary { color: #fff; }
.rmh-card__act a.btn--quiet { color: var(--ink); }
.rmh-icon, .rmh-tile__icon { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, #fff); border-radius: 0.6rem; }
.rmh-icon { width: 2.75rem; height: 2.75rem; }
.rmh-tile__icon { width: 2.25rem; height: 2.25rem; border-radius: 0.5rem; }
.rmh-icon svg { width: 1.5rem; height: 1.5rem; }
.rmh-tile__icon svg { width: 1.25rem; height: 1.25rem; }

.rmh-group { margin: 0 0 1.5rem; }
.rmh-group:last-child { margin-bottom: 0; }
.rmh-group__title { margin: 0 0 0.5rem; font-size: 0.78rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); }
.rmh-tiles { display: grid; gap: 0.5rem; grid-template-columns: 1fr; }
@media (min-width: 30rem) { .rmh-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 64rem) { .rmh-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.rmh-tile { display: flex; align-items: center; gap: 0.75rem; min-width: 0; min-height: 3.25rem; padding: 0.5rem 0.75rem; background: var(--card); border: 1px solid var(--line); border-radius: 0.6rem; color: var(--ink); font-weight: 600; text-decoration: none; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04); }
.rmh-tile:hover { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 4%, #fff); }
.rmh-tile__label { overflow-wrap: anywhere; line-height: 1.3; }
.rmh-card a:focus-visible, .rmh-tile:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* SOPs (v0.57.0): the Procedure row beside a form's title, and the footer link or menu. */
.rm-proc { margin: -0.5rem 0 0.9rem; font-size: 0.95rem; display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; align-items: baseline; }
.rm-proc[hidden] { display: none; }
.rm-proc__k { font-weight: 700; color: var(--ink-soft); }
.rm-sop { color: var(--accent, inherit); font-weight: 600; overflow-wrap: anywhere; }
.foot-sops { position: relative; }
.foot-sops[hidden] { display: none; }
.rm-sopmenu__btn { font: inherit; background: none; border: 0; padding: 0.4rem 0.25rem; min-height: 2.5rem; color: var(--ink-soft); text-decoration: underline; cursor: pointer; }
.rm-sopmenu__btn::after { content: " ▾"; }
.rm-sopmenu__list { position: absolute; bottom: 100%; right: 0; margin: 0 0 0.25rem; padding: 0.4rem 0; list-style: none; min-width: 12rem; max-width: 80vw; background: var(--card); border: 1px solid var(--line); border-radius: 0.5rem; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15); z-index: 20; }
.rm-sopmenu__list[hidden] { display: none; }
.rm-sopmenu__list li { margin: 0; }
.rm-sopmenu__list a { display: block; padding: 0.55rem 0.9rem; color: var(--ink); text-decoration: none; }
.rm-sopmenu__list a:hover, .rm-sopmenu__list a:focus-visible { background: var(--info-bg); }
