/* ============================================================================
   MASAR v5 — css5/9-pages-f.css
   Page layout for the ADMINISTRATION group only:

     .p-users   Users & Roles
     .p-int     Integrations
     .p-md      Master Data
     .p-set     Settings

   Nothing here restyles a kit component. It places them, and adds the five
   ornaments the kit has no vocabulary for yet — every one flagged in the
   handover as a kit candidate because more than one of these pages uses it:

     · a visually-hidden label        (.m-vh)      — an a11y utility
     · a granted / not-granted mark   (.p-ok-ic)   — the role matrix cell
     · a colour swatch                (.p-swatch)  — stream and facility keys
     · a fenced code block            (.p-code)    — payloads and queue shapes
     · a settings row                 (.p-set__row)— label, note and control

   Tokens only, logical properties only, both themes by inheritance.
   ========================================================================== */

/* ============================================================ shared atoms */

/* a label a screen reader needs and a sighted operator does not */
.m-vh{
  position:absolute;width:1px;height:1px;padding:0;margin:-1px;
  overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0;
}

/* the granted / not-granted mark in a permission cell */
.p-ok-ic{display:inline-flex;color:var(--ok);line-height:0}
.p-ok-ic svg{width:15px;height:15px}

/* a data colour, shown as itself */
.p-swatch{
  display:inline-block;width:10px;height:10px;border-radius:3px;
  margin-inline-end:6px;flex:0 0 auto;
  border:1px solid color-mix(in srgb, var(--text) 12%, transparent);
  vertical-align:-1px;
}

/* a fenced block: a payload, a message shape, a mapping sample */
.p-code{
  font-family:var(--font-mono);font-size:11.5px;line-height:1.65;
  color:var(--text-2);background:var(--surface-sunken);
  border:1px solid var(--line);border-radius:var(--r-sm);
  padding:var(--s-3);margin-block-start:var(--s-2);
  max-height:320px;overflow:auto;white-space:pre;tab-size:2;
}
.p-code--lg{max-height:560px;font-size:12px}

/* tone variants for the counter tile declared in 9-pages-c.css */
.p-count--ok b{color:var(--ok)}
.p-count--crit b{color:var(--critical)}
.p-count--warn b{color:var(--warn)}
.p-count span{display:inline-flex;align-items:center;gap:6px}
.p-count span svg{width:14px;height:14px;opacity:.75}

/* ================================================================== USERS */

.p-users__roles{align-items:start}
.p-users__rail{display:flex;flex-direction:column;gap:var(--s-4);min-width:0}

.p-role__grp{margin-block-end:var(--s-3)}
.p-role__grp > span{
  display:block;font:var(--ty-label-sm);color:var(--text-3);
  text-transform:uppercase;letter-spacing:.06em;margin-block-end:6px;
}
.p-role__act{margin-block-start:var(--s-5)}

/* the account form inside the drawer */
.p-form{display:flex;flex-direction:column;gap:var(--s-4)}
.p-form__row{display:grid;grid-template-columns:1fr 1fr;gap:var(--s-3)}
.p-form__switch{padding-block-start:var(--s-1)}

/* =========================================================== INTEGRATIONS */

.p-int__grid{align-items:start}

.p-int__legend{
  display:flex;align-items:center;gap:var(--s-4);flex-wrap:wrap;
  padding:var(--s-3) var(--card-pad-lg);border-top:1px solid var(--line-subtle);
  font:var(--ty-caption);color:var(--text-2);
}
.p-int__legend > span{display:inline-flex;align-items:center;gap:6px}
.p-int__legend .p-note{flex:1 1 260px}

.p-int__act{display:flex;flex-wrap:wrap;gap:var(--s-2);margin-block-start:var(--s-4)}

/* an endpoint is long and must never push the table sideways */
.p-int__url{display:inline-block;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.p-int__err{color:var(--critical);font:var(--ty-body-sm);line-height:1.5}

.p-int__io{margin-block-start:var(--s-4);align-items:start}

/* ============================================================ MASTER DATA */

/* the provenance summary — the most important panel on the page, so it is
   the one thing here that carries a little weight of its own */
.p-prov{display:flex;flex-direction:column}
.p-prov__head{
  display:flex;align-items:flex-start;gap:var(--s-3);
  padding:var(--card-pad-lg);border-bottom:1px solid var(--line-subtle);
}
.p-prov__ic{
  flex:0 0 auto;width:40px;height:40px;border-radius:var(--r-md);
  display:grid;place-items:center;
  background:var(--ok-soft);color:var(--ok);
}
.p-prov__x{display:flex;flex-direction:column;gap:4px;min-width:0}
.p-prov__x > b{font:var(--ty-h2);color:var(--text)}
.p-prov__x > span{font:var(--ty-body-sm);color:var(--text-2);line-height:1.65;max-width:76ch}

.p-prov__bar{padding:var(--s-4) var(--card-pad-lg);border-bottom:1px solid var(--line-subtle)}
.p-prov__legend{
  display:flex;align-items:center;gap:var(--s-5);flex-wrap:wrap;
  margin-block-start:var(--s-2);font:var(--ty-caption);color:var(--text-2);
}
.p-prov__legend > span{display:inline-flex;align-items:center;gap:6px}
.p-prov__legend b{color:var(--text);font-variant-numeric:tabular-nums}
.p-prov__tbl{min-width:0}

.p-md__policy{padding:var(--s-4) var(--card-pad-lg);border-top:1px solid var(--line-subtle)}
.p-md__policy .p-counts{margin-block-end:var(--s-3)}

/* =============================================================== SETTINGS */

.p-set__row{
  display:grid;grid-template-columns:minmax(0,1fr) minmax(220px,340px);
  gap:var(--s-4);align-items:center;
  padding:var(--s-4) 0;border-bottom:1px solid var(--line-subtle);
}
.p-set__row:last-child{border-bottom:0}
.p-set__row--wide{grid-template-columns:minmax(0,1fr);align-items:stretch}
.p-set__x{display:flex;flex-direction:column;gap:3px;min-width:0}
.p-set__x > b{font:var(--ty-label);color:var(--text)}
.p-set__x > span{font:var(--ty-body-sm);color:var(--text-2);line-height:1.6;max-width:74ch}
.p-set__c{display:flex;align-items:center;justify-content:flex-end;min-width:0}
.p-set__row--wide .p-set__c{justify-content:stretch;margin-block-start:var(--s-3)}
.p-set__row--wide .p-set__c > *{width:100%}

.p-set__switch{padding-block:var(--s-3);border-bottom:1px solid var(--line-subtle);width:100%}
.p-set__switch:last-child{border-bottom:0}
.p-set__switch.is-locked{opacity:.72;cursor:not-allowed}

.p-set__grid{
  display:grid;grid-template-columns:repeat(auto-fit,minmax(230px,1fr));
  gap:var(--s-4);margin-block-end:var(--s-4);
}
.p-set__num,.p-set__sel{min-width:0}

.p-set__clock{display:flex;flex-direction:column;align-items:flex-end;gap:2px}
.p-set__clock > b{font:var(--ty-metric-sm);color:var(--text);font-variant-numeric:tabular-nums}
.p-set__clock > span{font:var(--ty-caption);color:var(--text-3)}

.p-set__week{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:var(--s-2)}
.p-set__day{
  display:flex;flex-direction:column;gap:3px;padding:var(--s-3) var(--s-2);
  border:1px solid var(--line);border-radius:var(--r-sm);
  background:var(--surface);font:var(--ty-label-sm);color:var(--text);text-align:center;
}
.p-set__day > i{font:var(--ty-caption);color:var(--ok);font-style:normal}
.p-set__day.is-off{background:var(--surface-sunken);color:var(--text-3)}
.p-set__day.is-off > i{color:var(--text-3)}

.p-set__mods{display:flex;flex-direction:column;gap:var(--s-5);margin-block-start:var(--s-4)}
.p-set__modgrp > h4{
  font:var(--ty-label);color:var(--text-2);text-transform:uppercase;
  letter-spacing:.06em;margin-block-end:var(--s-2);
}

.p-set__bases{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:var(--s-2)}
.p-set__base{
  display:flex;flex-direction:column;gap:4px;align-items:flex-start;text-align:start;
  padding:var(--s-3);border:1px solid var(--line);border-radius:var(--r-md);
  background:var(--surface);cursor:pointer;color:var(--text);min-width:0;
  transition:border-color .14s ease, background .14s ease;
}
.p-set__base:hover{border-color:var(--line-strong);background:var(--surface-subtle)}
.p-set__base.is-on{border-color:var(--accent);background:var(--accent-soft)}
.p-set__base svg{color:var(--text-3)}
.p-set__base.is-on svg{color:var(--accent)}
.p-set__base > b{font:var(--ty-label);color:var(--text)}
.p-set__base > span{font:var(--ty-caption);color:var(--text-3);line-height:1.5}
.p-set__base:focus-visible{box-shadow:var(--focus-ring);outline:none}

.p-set__act{display:flex;flex-wrap:wrap;gap:var(--s-2);margin-block-start:var(--s-4)}
.p-set__policy{margin-block-start:var(--s-3)}
.p-set__about{margin-block-end:var(--s-4)}
.p-set__sync{display:flex;flex-direction:column;gap:var(--s-2)}

/* ------------------------------------------------ compact density
   The Appearance tab writes data-density on the document root. It tightens
   the two row heights every table and list in the product is drawn from,
   which is the whole control — nothing is restyled per page. */
html[data-density="compact"]{
  --row-h:34px;
  --row-h-lg:40px;
  --card-pad:12px;
  --card-pad-lg:15px;
}

/* ================================================================ NARROW */

@media (max-width:1180px){
  .p-set__row{grid-template-columns:minmax(0,1fr);align-items:stretch}
  .p-set__c{justify-content:flex-start;margin-block-start:var(--s-2)}
}

@media (max-width:900px){
  .p-form__row{grid-template-columns:minmax(0,1fr)}
  .p-set__week{grid-template-columns:repeat(2,minmax(0,1fr))}
  .p-prov__head{flex-direction:column}
  .p-int__legend{flex-direction:column;align-items:flex-start;gap:var(--s-2)}
}
