/* RG SecureSign — client signing experience.
   Prefix: rgss-. Loaded by public/client-portal/index.html.
   Phone-first: every size below is chosen so the whole flow works at 390px
   wide without horizontal scrolling. */

.rgss-wrap { display: block; }

/* ---------------------------------------------------------------- cards */
.rgss-bucket { margin: 0 0 22px; }
.rgss-bucket-head {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  margin: 0 0 10px;
}
.rgss-bucket-title {
  font-weight: 800; font-size: .95rem; color: #0A1628; letter-spacing: .2px;
}
.rgss-bucket-count {
  font-size: .72rem; font-weight: 800; color: #8a6d12;
  background: rgba(201,162,39,.16); border-radius: 999px; padding: 2px 9px;
}
.rgss-empty {
  border: 1px dashed #DDE3EC; border-radius: 12px; padding: 22px 18px;
  color: #64748B; font-size: .87rem; line-height: 1.6; background: #FBFCFE;
}
.rgss-empty strong { display: block; color: #0A1628; margin-bottom: 6px; }

.rgss-card {
  border: 1px solid #ECEFF4; border-left: 3px solid #C9A227; border-radius: 12px;
  background: #fff; padding: 14px 15px; margin-bottom: 10px;
  box-shadow: 0 1px 2px rgba(10,22,40,.04);
}
.rgss-card-title {
  font-weight: 800; font-size: .96rem; color: #0A1628; line-height: 1.35;
  margin-bottom: 8px; word-break: break-word;
}
.rgss-meta {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px; margin-bottom: 12px;
}
.rgss-meta div { min-width: 0; }
.rgss-meta span {
  display: block; font-size: .68rem; font-weight: 800; letter-spacing: .07em;
  text-transform: uppercase; color: #94A3B8; margin-bottom: 2px;
}
.rgss-meta b {
  display: block; font-size: .84rem; font-weight: 700; color: #1F2A3C;
  word-break: break-word;
}
.rgss-badge {
  display: inline-block; font-size: .68rem; font-weight: 800; letter-spacing: .05em;
  text-transform: uppercase; padding: 4px 10px; border-radius: 999px;
  white-space: nowrap;
}
.rgss-badge.act  { background: rgba(217,119,6,.14);  color: #9A5B04; }
.rgss-badge.prog { background: rgba(47,111,176,.14); color: #235388; }
.rgss-badge.wait { background: rgba(100,116,139,.16); color: #475569; }
.rgss-badge.done { background: rgba(15,157,107,.14); color: #0B7A53; }
.rgss-badge.past { background: rgba(100,116,139,.12); color: #64748B; }

.rgss-btn {
  min-height: 46px; width: 100%; border: 0; border-radius: 10px; padding: 0 16px;
  background: #0A1628; color: #fff; font: inherit; font-size: .92rem; font-weight: 800;
  cursor: pointer;
}
.rgss-btn.gold { background: #C9A227; color: #0A1628; }
.rgss-btn.ghost { background: transparent; color: #0A1628; border: 1px solid #D8DEE6; }
.rgss-btn.warn { background: transparent; color: #7A1F1F; border: 1px solid #E7C6C6; }
.rgss-btn[disabled] { opacity: .45; cursor: not-allowed; }
.rgss-btn + .rgss-btn { margin-top: 8px; }
.rgss-btnrow { display: grid; gap: 8px; }
@media (min-width: 620px) {
  .rgss-btnrow { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
  .rgss-btn + .rgss-btn { margin-top: 0; }
}

/* ------------------------------------------------------------ workspace */
.rgss-ws {
  position: fixed; inset: 0; z-index: 10000; background: #F4F6FA;
  display: flex; flex-direction: column;
}
.rgss-ws-head {
  flex: 0 0 auto; background: #0A1628; color: #fff;
  padding: 10px 12px; display: flex; align-items: center; gap: 10px;
}
.rgss-ws-head h2 {
  margin: 0; font-size: .92rem; font-weight: 800; line-height: 1.3;
  flex: 1 1 auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rgss-ws-head small { display: block; font-size: .7rem; opacity: .72; font-weight: 600; }
.rgss-x {
  flex: 0 0 auto; background: none; border: 0; color: #fff; font-size: 1.5rem;
  line-height: 1; cursor: pointer; padding: 4px 8px;
}
.rgss-steps {
  flex: 0 0 auto; display: flex; gap: 2px; background: #0A1628;
  padding: 0 8px 8px; overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.rgss-step {
  flex: 1 1 0; min-width: 74px; text-align: center; font-size: .64rem;
  font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  color: rgba(255,255,255,.45); padding: 6px 4px 5px;
  border-bottom: 2px solid rgba(255,255,255,.14); white-space: nowrap;
}
.rgss-step.done { color: #7FD8B4; border-bottom-color: #0F9D6B; }
.rgss-step.now  { color: #E6C863; border-bottom-color: #C9A227; }

.rgss-ws-body { flex: 1 1 auto; overflow: hidden; position: relative; }

/* ------------------------------------------------------------- viewer */
.rgss-doc {
  position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch; scroll-behavior: smooth;
  padding: 12px 8px 18px; background: #F4F6FA;
}
@media (prefers-reduced-motion: reduce) { .rgss-doc { scroll-behavior: auto; } }
.rgss-page {
  position: relative; margin: 0 auto 12px; background: #fff;
  box-shadow: 0 2px 10px rgba(10,22,40,.10); border-radius: 3px;
  max-width: 100%; overflow: hidden;
}
.rgss-page canvas { display: block; width: 100%; height: auto; }
.rgss-page-ph {
  display: flex; align-items: center; justify-content: center;
  color: #B4BECD; font-size: .8rem; font-weight: 700;
}
.rgss-page-no {
  position: absolute; right: 6px; bottom: 6px; font-size: .64rem; font-weight: 800;
  color: #94A3B8; background: rgba(255,255,255,.85); border-radius: 4px;
  padding: 1px 6px; pointer-events: none;
}

/* field overlays, positioned as fractions of the rendered page */
.rgss-field {
  position: absolute; border: 2px dashed #C9A227; border-radius: 4px;
  background: rgba(201,162,39,.10); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: .66rem; font-weight: 800; color: #8a6d12; text-align: center;
  padding: 2px; overflow: hidden; line-height: 1.15;
}
.rgss-field.filled {
  border-style: solid; border-color: #0F9D6B; background: rgba(15,157,107,.10);
  color: #0B7A53;
}
.rgss-field.target {
  box-shadow: 0 0 0 3px rgba(201,162,39,.45);
}
.rgss-field img { max-width: 100%; max-height: 100%; object-fit: contain; }
.rgss-field-val {
  width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: #0A1628; font-weight: 700;
}

/* --------------------------------------------------------------- footer */
.rgss-ws-foot {
  flex: 0 0 auto; background: #fff; border-top: 1px solid #E4E9F0;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
  display: grid; gap: 8px;
}
.rgss-pager {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.rgss-pager button {
  min-width: 44px; min-height: 38px; border: 1px solid #D8DEE6; border-radius: 8px;
  background: #fff; font: inherit; font-weight: 800; color: #0A1628; cursor: pointer;
}
.rgss-pager button[disabled] { opacity: .4; cursor: not-allowed; }
.rgss-counter {
  flex: 1 1 auto; text-align: center; font-size: .8rem; font-weight: 800;
  color: #475569; font-variant-numeric: tabular-nums;
}
.rgss-req {
  font-size: .78rem; font-weight: 700; color: #9A5B04; text-align: center;
  line-height: 1.4;
}
.rgss-req.ok { color: #0B7A53; }

/* ----------------------------------------------------------- bottom sheet */
.rgss-sheet-back {
  position: fixed; inset: 0; z-index: 10010; background: rgba(10,22,40,.55);
  display: flex; align-items: flex-end; justify-content: center;
}
.rgss-sheet {
  background: #fff; width: 100%; max-width: 640px; max-height: 92vh;
  border-radius: 16px 16px 0 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -6px 28px rgba(10,22,40,.28);
}
@media (prefers-reduced-motion: no-preference) {
  .rgss-sheet { animation: rgssUp .22s cubic-bezier(.2,.7,.3,1); }
  @keyframes rgssUp { from { transform: translateY(14px); opacity: .6; } to { transform: none; opacity: 1; } }
}
.rgss-sheet h3 {
  margin: 0 0 4px; font-size: 1.02rem; font-weight: 800; color: #0A1628; line-height: 1.3;
}
.rgss-sheet p { margin: 0 0 12px; font-size: .86rem; line-height: 1.6; color: #475569; }
.rgss-consent {
  border: 1px solid #E4E9F0; border-radius: 10px; background: #FBFCFE;
  padding: 12px 13px; max-height: 40vh; overflow-y: auto; margin-bottom: 12px;
  font-size: .82rem; line-height: 1.65; color: #1F2A3C;
  white-space: pre-wrap; word-break: break-word;
}
.rgss-check {
  display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px;
  font-size: .86rem; line-height: 1.5; color: #0A1628; cursor: pointer;
}
.rgss-check input { flex: 0 0 auto; width: 22px; height: 22px; margin: 1px 0 0; }
.rgss-note {
  font-size: .8rem; line-height: 1.6; border-radius: 9px; padding: 10px 12px;
  margin-bottom: 12px;
}
.rgss-note.warn { background: #FFF7ED; color: #9A5B04; border: 1px solid #F5DEB8; }
.rgss-note.bad  { background: #FEF2F2; color: #7A1F1F; border: 1px solid #F0CFCF; }
.rgss-note.good { background: #F0FBF6; color: #0B7A53; border: 1px solid #C7EBDC; }
.rgss-note.info { background: #F5F8FC; color: #334155; border: 1px solid #E1E9F2; }

.rgss-input {
  width: 100%; min-height: 46px; border: 1px solid #D8DEE6; border-radius: 9px;
  padding: 0 12px; font: inherit; font-size: .92rem; color: #0A1628; background: #fff;
  box-sizing: border-box; margin-bottom: 12px;
}
.rgss-input:focus { border-color: #C9A227; outline: none; box-shadow: 0 0 0 3px rgba(201,162,39,.22); }
.rgss-otp {
  letter-spacing: 10px; text-align: center; font-size: 22px; font-weight: 800;
}
.rgss-label {
  display: block; font-size: .7rem; font-weight: 800; letter-spacing: .06em;
  text-transform: uppercase; color: #64748B; margin: 0 0 6px;
}

/* -------------------------------------------------------------- sig pad */
.rgss-padwrap { margin-bottom: 12px; }
.rgss-pad {
  width: 100%; height: 240px; display: block; touch-action: none;
  border: 1px solid #D8DEE6; border-radius: 10px; background: #fff;
  background-image: linear-gradient(#E9EDF3 1px, transparent 1px);
  background-size: 100% 100%; background-position: 0 78%; background-repeat: no-repeat;
}
@media (min-height: 720px) { .rgss-pad { height: 300px; } }
.rgss-padhint {
  font-size: .78rem; color: #64748B; line-height: 1.5; margin: 8px 0 10px;
}
.rgss-padbar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }

.rgss-sum { display: grid; gap: 9px; margin-bottom: 14px; }
.rgss-sum div {
  display: flex; justify-content: space-between; gap: 12px; font-size: .84rem;
  border-bottom: 1px solid #EEF1F6; padding-bottom: 8px;
}
.rgss-sum span { color: #64748B; font-weight: 700; }
.rgss-sum b { color: #0A1628; font-weight: 800; text-align: right; word-break: break-word; }

.rgss-spin {
  display: inline-block; width: 15px; height: 15px; vertical-align: -2px;
  border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%;
  margin-right: 8px;
}
@media (prefers-reduced-motion: no-preference) {
  .rgss-spin { animation: rgssSpin .7s linear infinite; }
  @keyframes rgssSpin { to { transform: rotate(360deg); } }
}

/* ---------- upload a signature instead of drawing one ---------- */
.rgss-padupload {
  border-top: 1px solid #EEF1F6; margin-top: 4px; padding-top: 12px;
  text-align: center;
}
.rgss-padupload > span {
  display: block; color: #94A3B8; font-size: 11px; font-weight: 800;
  letter-spacing: .08em; text-transform: uppercase; margin-bottom: 8px;
}
/* The control is a <label for> over a hidden <input type=file>, so it needs
   the button's cursor and centring explicitly. */
.rgss-padupload label.rgss-btn {
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; width: 100%;
}
.rgss-hint {
  color: #64748B; font-size: 11.5px; line-height: 1.5;
  margin: 8px 0 0; text-align: left;
}
