/* Country register: the Obligations workspace (filter facets, results, detail panel).
   Loaded after country-register-redesign.css and uses its --rg-* tokens, so light and dark follow it. */

/* ---------- layout ---------- */
.rgw-grid { display: block; }
.rgw-grid > * { min-width: 0; }
.rgw-main { container-type: inline-size; container-name: rgwmain; min-width: 0; }
.rgw-panel-col { margin-top: 18px; }

/* Wide screens: the filters sit beside the table and the open provision is a drawer over the right-hand
   edge (about 520px), so the table keeps its width and the panel has room to read. Nothing is docked in
   a narrow third column any more, and nothing shows until a provision is chosen. */
@media (min-width: 1200px) {
  .rgw-grid { display: grid; grid-template-columns: 208px minmax(0, 1fr); gap: 16px; align-items: start; }
  .rgw-grid.rgw-no-facets { grid-template-columns: minmax(0, 1fr); }
  .rgw-facets-col { position: sticky; top: 12px; max-height: calc(100vh - 24px); margin-top: 0; overflow-y: auto; overscroll-behavior: contain; }
  .rgw-panel-col { position: fixed; z-index: 910; top: 12px; right: 16px; bottom: 12px; width: min(520px, calc(100vw - 32px)); margin: 0; display: flex; flex-direction: column; }
  .rgw-panel-col:has([data-rgw-state="empty"]) { display: none; }
  .rgw-panel-col .rgw-panel { box-shadow: 0 12px 40px rgba(1, 21, 48, .28); }
  /* Light backdrop behind the drawer (inside the drawer's own stacking context, so z-index -1 sits under it). */
  .rg-js .rgw-backdrop { position: fixed; inset: 0; z-index: -1; background: rgba(1, 21, 48, .18); }
  .rg-js .rgw-panel:not([data-rgw-state="empty"]) + .rgw-backdrop { display: block; }
  html.rgw-sheet-open { overflow: hidden; }
}
@media (min-width: 1500px) {
  .rgw-grid { grid-template-columns: 232px minmax(0, 1fr); gap: 20px; }
  .rgw-grid.rgw-no-facets { grid-template-columns: minmax(0, 1fr); }
}
@media (min-width: 2000px) {
  .rgw-grid { grid-template-columns: 264px minmax(0, 1fr); gap: 24px; }
  .rgw-grid.rgw-no-facets { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- facets ---------- */
.rgw-facet-form { background: var(--rg-surface); border: 1px solid var(--rg-line); border-radius: var(--rg-radius); box-shadow: var(--rg-shadow); padding: 12px 14px 14px; }
.rgw-facets-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.country-handbook-page .rg-page .rgw-facets-head h3 { margin: 0; font-size: 15px; font-weight: 800; }
.rgw-facet { margin: 0; padding: 10px 0 8px; border: 0; border-top: 1px solid var(--rg-line); min-width: 0; }
.rgw-facets-head + .rgw-facet { border-top: 0; }
.rgw-facet legend { padding: 0; margin: 0 0 6px; font-size: 12px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--rg-muted); }
.rgw-facet-list { list-style: none; margin: 0; padding: 0; }
.rgw-facet-list.is-long { max-height: 232px; overflow-y: auto; padding-right: 4px; }
.rgw-opt { display: flex; align-items: flex-start; gap: 8px; min-height: 30px; padding: 4px 6px; margin: 0 -6px; border-radius: 6px; font-size: 13.5px; line-height: 1.3; color: var(--rg-ink); cursor: pointer; }
.rgw-opt:hover { background: var(--rg-wash); }
.rgw-opt input { flex: 0 0 auto; margin: 2px 0 0; accent-color: var(--rg-gold, #e8b923); width: 16px; height: 16px; }
.rgw-opt-label { flex: 1 1 auto; min-width: 0; overflow-wrap: break-word; }
.rgw-opt-count { flex: 0 0 auto; font-size: 12px; font-variant-numeric: tabular-nums; color: var(--rg-muted); padding-top: 1px; }
.rgw-opt.is-zero { color: var(--rg-faint); cursor: default; }
.rgw-opt.is-zero:hover { background: transparent; }
.rgw-opt input:checked ~ .rgw-opt-label { font-weight: 700; }
.rgw-opt:has(input:focus-visible) { outline: 2px solid var(--rg-navy); outline-offset: 1px; }
.rgw-apply { margin-top: 10px; width: 100%; min-height: 44px; justify-content: center; }
.rg-js .rgw-apply { display: none; }
.rgw-filters-toggle { display: none; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; border: 1px solid var(--rg-line-strong); border-radius: 8px; background: var(--rg-surface); color: var(--rg-ink); font: inherit; font-weight: 700; cursor: pointer; }
.rgw-filters-count { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--rg-gold, #e8b923); color: #011530; font-size: 12px; font-weight: 800; }

@media (max-width: 1199px) {
  .rg-js .rgw-filters-toggle { display: inline-flex; }
  .rg-js .rgw-facet-form { display: none; margin-top: 8px; }
  .rg-js .rgw-facets.is-open .rgw-facet-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 18px; }
  .rgw-facet-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 18px; }
  .rgw-facets-head, .rgw-apply { grid-column: 1 / -1; }
  .rgw-facet-list.is-long { max-height: 180px; }
  .rgw-facets-col { margin-bottom: 12px; }
  .rg-js .rgw-facets-head h3 { display: none; }
  .rgw-facet { border-top: 1px solid var(--rg-line); }
}
@media (max-width: 760px) {
  .rg-js .rgw-facets.is-open .rgw-facet-form, .rgw-facet-form { grid-template-columns: 1fr; }
  .rg-js .rgw-apply { display: block; }
  .rgw-opt { min-height: 44px; align-items: center; }
  .rgw-opt input { margin: 0; }
}

/* ---------- group by ---------- */
.rgw-groupby { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 0 0 10px; }
.rgw-gb-label { font-size: 12px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--rg-muted); }
.rgw-gb-links { display: flex; flex-wrap: wrap; gap: 4px; padding: 3px; background: var(--rg-wash); border: 1px solid var(--rg-line); border-radius: 10px; }
.rgw-gb { display: inline-flex; align-items: center; min-height: 34px; padding: 0 12px; border-radius: 7px; font-size: 13px; font-weight: 700; color: var(--rg-muted) !important; text-decoration: none !important; white-space: nowrap; }
.rgw-gb:hover { color: var(--rg-ink) !important; background: var(--rg-surface); }
.rgw-gb.is-current { background: var(--rg-surface); color: var(--rg-ink) !important; box-shadow: 0 0 0 1px var(--rg-line-strong), var(--rg-shadow); }
.country-handbook-page .rg-page .rgw-gb-note { flex: 1 1 100%; margin: 0; font-size: 12.5px; color: var(--rg-muted); }
.rg-table .rgw-group-head th { padding: 10px 14px; background: var(--rg-wash); border-bottom: 1px solid var(--rg-line-strong); border-top: 1px solid var(--rg-line-strong); font-size: 13px; text-align: left; }
.rgw-group-name { font-weight: 800; color: var(--rg-ink); margin-right: 10px; }
.rgw-group-count, .rgw-group-page { font-weight: 600; color: var(--rg-muted); margin-right: 10px; }
.rgw-group:first-of-type .rgw-group-head th { border-top: 0; }
.rg-table tbody.rgw-group:last-child tr:last-child > * { border-bottom: 0; }

/* ---------- instrument cards: a wrapping grid (2 across, 3 from 1500px, 4 from 1800px) ---------- */
@media (min-width: 761px) {
  .rgw-main .ch-register-instruments { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
}
@media (min-width: 1500px) { .rgw-main .ch-register-instruments { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1800px) { .rgw-main .ch-register-instruments { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.rgw-main .rg-more-instruments .ch-register-instruments { margin-top: 10px; }

/* ---------- table inside the centre column ---------- */
.rg-table .rg-row.is-active a[data-rgw-pick] { text-decoration: underline; }
/* Provision cell carries the instrument as a muted sub-line; Theme and Applies to stay visible. */
.rgw-ref-inst { display: block; margin-top: 2px; font-size: 12.5px; font-weight: 500; color: var(--rg-muted); }
.rgw-sort-also { font-weight: 600; white-space: nowrap; }
.rgw-sort-also a.rg-sort { font-size: 12px; }
.rg-table .rg-ref { min-width: 120px; max-width: 220px; }
.rg-table td[data-label="Theme"], .rg-table td[data-label="Applies to"] { min-width: 96px; max-width: 150px; }
@container rgwmain (max-width: 700px) {
  .rg-table th, .rg-table td { padding: 10px 8px; }
  .rg-table { font-size: 13.5px; }
  .rg-table td[data-label="Theme"], .rg-table td[data-label="Applies to"] { min-width: 80px; max-width: 120px; }
}

/* ---------- detail panel ---------- */
.rgw-panel { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; background: var(--rg-surface); color: var(--rg-ink); border: 1px solid var(--rg-line-strong); border-radius: var(--rg-radius); box-shadow: var(--rg-shadow); overflow: hidden; }
.rgw-panel:focus { outline: none; }
.rgw-panel:focus-visible { outline: 2px solid var(--rg-blue); outline-offset: 2px; }
.rgw-panel-body { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.rgw-detail { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.rgw-detail-head { flex: 0 0 auto; padding: 14px 18px 10px; }
.rgw-detail-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.country-handbook-page .rg-page .rgw-kicker { margin: 0 0 2px; font-size: 13px; font-weight: 700; color: var(--rg-muted); overflow-wrap: break-word; min-width: 0; }
.rgw-kicker a { color: var(--rg-muted) !important; text-decoration: none; }
.rgw-kicker a:hover { color: var(--rg-ink) !important; text-decoration: underline; }
.rgw-close { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; margin: -4px -6px 0 0; border: 1px solid var(--rg-line-strong); border-radius: 8px; background: var(--rg-surface); color: var(--rg-ink) !important; font-size: 24px; line-height: 1; text-decoration: none !important; cursor: pointer; }
.rgw-close:hover { background: var(--rg-wash); }
.country-handbook-page .rg-page .rgw-title, .country-handbook-page .rg-page .rgw-empty-title { margin: 0 0 4px; font-size: 22px; line-height: 1.2; font-weight: 800; overflow-wrap: break-word; }
.rgw-title:focus { outline: none; }
.rgw-title:focus-visible { outline: 2px solid var(--rg-blue); outline-offset: 3px; }
.country-handbook-page .rg-page .rgw-heading { margin: 0 0 8px; font-size: 14px; color: var(--rg-muted); line-height: 1.4; }
.country-handbook-page .rg-page .rgw-chips { margin: 0 0 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.rgw-stepper { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0 0; }
.rgw-step { display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border: 1px solid var(--rg-line-strong); border-radius: 8px; font-size: 13px; font-weight: 700; color: var(--rg-ink) !important; text-decoration: none !important; background: var(--rg-surface); white-space: nowrap; }
a.rgw-step:hover { background: var(--rg-wash); }
.rgw-step.is-off { color: var(--rg-faint) !important; background: transparent; border-style: dashed; }
.rgw-step-pos { font-size: 13px; font-weight: 700; color: var(--rg-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.country-handbook-page .rg-page .rgw-step-note { margin: 4px 0 0; font-size: 12.5px; color: var(--rg-muted); }

.rgw-tabs { display: none; flex: 0 0 auto; flex-wrap: wrap; gap: 0 4px; padding: 0 6px; border-top: 1px solid var(--rg-line); border-bottom: 1px solid var(--rg-line-strong); }
.rg-js .rgw-tabs { display: flex; }
.country-handbook-page .rg-page .rgw-tab { flex: 0 0 auto; min-height: 40px; padding: 0 6px; border: 0; border-bottom: 3px solid transparent; margin-bottom: -1px; background: transparent; color: var(--rg-muted); font: inherit; font-size: 12.5px; font-weight: 700; line-height: 1; white-space: nowrap; cursor: pointer; border-radius: 0; box-shadow: none; }
.rgw-tab:hover { color: var(--rg-ink); background: transparent; }
.country-handbook-page .rg-page .rgw-tab[aria-selected="true"] { color: var(--rg-ink); border-bottom-color: var(--rg-gold, #e8b923); background: transparent; box-shadow: none; }
.rgw-tab:focus-visible { outline: 2px solid var(--rg-blue); outline-offset: -2px; }
.rgw-tab-count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--rg-wash); font-size: 11.5px; line-height: 18px; text-align: center; color: var(--rg-muted); }
.rgw-tabpanels, .rgw-inst-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 14px 18px 18px; overscroll-behavior: contain; }
.rgw-tabpanel:focus-visible { outline: 2px solid var(--rg-blue); outline-offset: 2px; }
.rgw-tabpanel + .rgw-tabpanel { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--rg-line); }
.rg-js .rgw-tabpanel + .rgw-tabpanel { margin-top: 0; padding-top: 0; border-top: 0; }
.country-handbook-page .rg-page .rgw-panel-heading { margin: 0 0 8px; font-size: 14px; font-weight: 800; }
.rg-js .rgw-panel-heading { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.country-handbook-page .rg-page .rgw-tabpanel h4, .country-handbook-page .rg-page .rgw-rel h4 { margin: 0 0 6px; font-size: 14px; font-weight: 800; }
.country-handbook-page .rg-page .rgw-tabpanel p, .country-handbook-page .rg-page .rgw-inst-body p { font-size: 14px; line-height: 1.55; }
.rgw-tabpanel section { margin-bottom: 16px; }
.rgw-facts { margin: 0 0 14px; display: grid; gap: 10px; }
.rgw-facts > div { min-width: 0; }
.rgw-facts dt { font-size: 11.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--rg-muted); margin: 0 0 1px; }
.rgw-facts dd { margin: 0; font-size: 14px; line-height: 1.45; overflow-wrap: break-word; }
.rgw-counts { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 10px 12px; background: var(--rg-wash); border-radius: 8px; }
.rgw-counts dd { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.rgw-hash { font-size: 12.5px; word-break: break-all; }
.rgw-tabpanel .ch-register-original { margin: 8px 0 12px; }
.rgw-tabpanel .ch-register-original p { white-space: pre-wrap; }
.rgw-tabpanel .rg-policy { margin: 0 0 10px; padding: 8px 10px; background: var(--rg-wash); border-radius: 8px; font-size: 13px; color: var(--rg-muted); }
.rgw-rel { margin-bottom: 18px; }
.rgw-rel-count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--rg-wash); font-size: 11.5px; font-weight: 700; line-height: 18px; text-align: center; color: var(--rg-muted); }
.country-handbook-page .rg-page .rgw-rel-group h5 { margin: 10px 0 4px; font-size: 13px; font-weight: 800; color: var(--rg-muted); }
.rgw-rel ul { list-style: none; margin: 0; padding: 0; }
.rgw-rel li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; padding: 6px 0; border-top: 1px solid var(--rg-line); font-size: 14px; }
.rgw-rel li:first-child { border-top: 0; }
.rgw-rel li a { font-weight: 700; display: inline-flex; align-items: center; min-height: 28px; }
.rgw-rel-heading { flex: 1 1 100%; color: var(--rg-muted); font-size: 13px; line-height: 1.4; }
.rgw-foot { flex: 0 0 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 18px; border-top: 1px solid var(--rg-line-strong); background: var(--rg-wash); }
.rgw-foot .rg-btn-gold { background: var(--rg-gold, #e8b923); border-color: var(--rg-gold, #e8b923); color: #011530 !important; }
.rgw-empty { padding: 18px; }
.rgw-empty p { margin: 6px 0 0; font-size: 14px; color: var(--rg-muted); line-height: 1.5; }
.rgw-assessment { margin-top: 12px; }
.rgw-assessment .ch-register-assessment { margin: 0; }
.rgw-backdrop { display: none; }

/* A selected instrument card */
.rg-inst.is-inspected { box-shadow: 0 0 0 2px var(--rg-gold, #e8b923); }
.rgw-inst-link { color: inherit !important; text-decoration: none; }
.rgw-inst-link:hover { text-decoration: underline; }
.rgw-inst-link:focus-visible { outline: 2px solid var(--rg-navy); outline-offset: 2px; border-radius: 3px; }

/* Empty state sits quietly on desktop; below the desktop layout nothing is shown until something is chosen. */
@media (min-width: 1200px) {
  .rgw-panel[data-rgw-state="empty"] { border-style: dashed; box-shadow: none; background: transparent; }
  .rgw-panel[data-rgw-state="empty"] .rgw-empty { padding: 24px 18px; }
}

/* ---------- below the desktop layout: a slide-over panel (a full-screen sheet on phones) ---------- */
@media (max-width: 1199px) {
  .rgw-panel-col:has([data-rgw-state="empty"]) { display: none; }
  .rg-js .rgw-panel { position: fixed; z-index: 910; top: 0; right: 0; bottom: 0; width: min(480px, 100vw); border-radius: 0; border-width: 0 0 0 1px; box-shadow: -8px 0 32px rgba(1, 21, 48, .22); }
  .rg-js .rgw-panel[data-rgw-state="empty"] { display: none; }
  .rg-js .rgw-backdrop { position: fixed; inset: 0; z-index: 900; background: rgba(1, 21, 48, .38); }
  .rg-js .rgw-panel:not([data-rgw-state="empty"]) + .rgw-backdrop { display: block; }
  html.rgw-sheet-open { overflow: hidden; }
}
@media (max-width: 760px) {
  .rg-js .rgw-panel { width: 100vw; border-width: 0; }
  .rgw-detail-head { padding-inline: 16px; }
  .rgw-tabpanels, .rgw-inst-body, .rgw-foot { padding-inline: 16px; }
  .country-handbook-page .rg-page .rgw-tab { min-height: 44px; }
  .country-handbook-page .rg-page .rgw-foot .rg-btn { min-height: 44px; }
  .rgw-step { min-height: 44px; }
  .rgw-close { width: 44px; height: 44px; }
}
@media (prefers-reduced-motion: no-preference) {
  @media (max-width: 1199px) {
    .rg-js .rgw-panel:not([data-rgw-state="empty"]) { animation: rgw-in .18s ease-out; }
  }
}
@keyframes rgw-in { from { transform: translateX(24px); opacity: .4; } to { transform: none; opacity: 1; } }
@media print {
  .rgw-facets-col, .rgw-panel-col, .rgw-groupby { display: none !important; }
}

/* ---------- search: one inline row (input, button, "More filters") ---------- */
.rg-page .rg-filters.ch-filter-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 6px 12px; padding: 12px 14px; margin-bottom: 12px; }
.rg-page .rg-filters.ch-filter-form > .ch-field.ch-search { flex: 1 1 260px; min-width: 0; margin: 0; }
.rg-page .rg-filters .rg-filter-actions { flex: 0 0 auto; align-self: flex-end; }
.rg-page .rg-filters .rg-filter-actions .ch-button { min-height: 44px; }
.rg-page .rg-filters .rg-more-filters { flex: 0 0 auto; align-self: center; }
.rg-page .rg-filters .rg-more-filters > summary { min-height: 44px; }
.rg-page .rg-filters .rg-more-filters[open] { flex: 1 1 100%; }
@media (max-width: 760px) {
  .rg-page .rg-filters.ch-filter-form > .ch-field.ch-search { flex-basis: 100%; }
  .rg-page .rg-filters .rg-filter-actions { flex: 1 1 auto; }
  .rg-page .rg-filters .rg-filter-actions .ch-button { width: 100%; justify-content: center; }
}

/* Chips in the table wrap between words, never inside them. */
.rg-table td .rg-chip { overflow-wrap: normal; word-break: normal; hyphens: none; }
.rg-table td[data-label="Theme"], .rg-table td[data-label="Applies to"] { min-width: 108px; max-width: 160px; }

@media (max-width: 980px) {
  .country-handbook-page button,
  .country-handbook-page .rg-page select,
  .country-handbook-page .rg-page input[type="search"],
  .country-handbook-page .rg-page .rgw-tab,
  .country-handbook-page .rg-page .rgw-close,
  .country-handbook-page .rg-page .rgw-step,
  .country-handbook-page .rg-page .rgw-opt,
  .country-handbook-page .rg-page .rgw-foot .rg-btn { min-height: 44px; min-width: 44px; }
}

@media (min-width: 1200px) and (max-width: 1499px) {
  .rgw-grid { grid-template-columns: 192px minmax(0, 1fr); gap: 14px; }
  .rgw-grid.rgw-no-facets { grid-template-columns: minmax(0, 1fr); }
  .rg-table td[data-label="Theme"], .rg-table td[data-label="Applies to"] { min-width: 92px; max-width: 120px; }
  .rg-table td.rg-sum { min-width: 150px; }
}

/* The firm types a provision applies to read in full in the table (the old three-line cut-off hid the
   part that tells a lawyer from a notary). */
.rg-table td[data-label="Applies to"] .rg-chip { display: inline-flex; -webkit-line-clamp: unset; overflow: visible; max-width: 100%; border-radius: 12px; }
