/* Members and roles, policies, audit log. Loaded after console.css. Only what the component set (app.css) doesn't
   cover; every size, weight, radius, spacing and colour is a token (tokens.css). */

/* shared: fieldsets, multi-value chip input */
.sheet-first { margin-top: 0; }
.chip.bad { background: var(--bad-wash); color: var(--bad-ink); }
.chip-input {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1); min-height: var(--h-md); padding: var(--s-1); cursor: text;
  border: 1px solid var(--line-2); border-radius: var(--r-s); background: var(--panel); transition: border-color .15s, box-shadow .15s;
}
.chip-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.chip-input .chips:empty { display: none; }
.chip-input input { flex: 1; min-width: 160px; border: 0; background: none; height: calc(var(--h-sm) - 2px); padding: 0 var(--s-1); outline: none; box-shadow: none; }
.chip-input:has(input[aria-invalid="true"]) { border-color: var(--bad); }
.chip-input:has(input[aria-invalid="true"]):focus-within { box-shadow: 0 0 0 3px var(--bad-wash); }
/* the box is the field: its ring shows focus (the caret shows where typing goes), so the input inside draws none */
.chip-input input:focus, .chip-input input:focus-visible { box-shadow: none; outline: none; }

/* members */
.person { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.person .cell-sub { overflow: hidden; text-overflow: ellipsis; }
select.role-sel { min-width: 118px; }
.role-ro { display: inline-flex; align-items: center; gap: var(--s-1); height: var(--h-sm); font-weight: var(--w-medium); border-radius: var(--r-s); cursor: default; }
.role-ro .i { width: 12px; height: 12px; color: var(--ink-4); }
.role-ro:focus-visible { box-shadow: var(--focus); }
.sheet-person { gap: var(--s-3); }
.sheet-person .avatar { width: var(--s-8); height: var(--s-8); font-size: var(--fs-small); }
.role-note { margin: var(--s-2) 0 0; }

/* invitation results */
.inv-res { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-3); }
.inv-res li { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-3); border: 1px solid var(--line); border-radius: var(--r-m); }
.inv-res li.bad { background: var(--bad-wash); border-color: transparent; }
.inv-res-h { justify-content: space-between; flex-wrap: wrap; }
.inv-why { margin: 0; font: var(--f-small); color: var(--bad-ink); }
.roles-pick { grid-template-columns: 1fr 1fr; }

/* roles: the strip of role descriptions, and the permission table */
.roles-list { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin-bottom: var(--s-4); }
.role-card { padding: var(--s-3) var(--s-4); border-left: 1px solid var(--line); }
.role-card:first-child { border-left: 0; }
.role-card p { margin: var(--s-1) 0 0; color: var(--ink-2); }
.tbl.matrix th[scope="row"] { font: var(--f-body); color: var(--ink); white-space: normal; min-width: 240px; padding-top: var(--s-1); padding-bottom: var(--s-1); }
.tbl.matrix th[scope="row"] span { display: block; }
.tbl.matrix .c { text-align: center; width: 92px; }
.tbl.matrix td.yes .i { color: var(--good); vertical-align: middle; }
.tbl.matrix .dash { display: inline-block; width: 10px; height: 2px; border-radius: var(--r-pill); background: var(--ink-4); vertical-align: middle; opacity: .6; }
/* row headers end like the cells beside them (app.css clears the last row's rule on td only) */
.tbl.matrix tr:last-child th[scope="row"], .tbl.diff tr:last-child th[scope="row"] { border-bottom: 0; }

/* policies */
.pol + .pol { margin-top: var(--s-4); }
.pol > .sec-h { padding-bottom: var(--s-4); }
.pol .sec-d a { text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
.pol-row { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) 120px; gap: var(--s-5); align-items: start; padding: var(--s-4); border-top: 1px solid var(--line); }
.pol > .pol-row:first-child { border-top: 0; }
.pol-t .sec-h.bare { margin-bottom: 0; }
.pol-t .badge.code { margin-top: var(--s-1); }
.pol-v { display: flex; flex-direction: column; gap: var(--s-2); align-items: flex-start; min-width: 0; }
.pol-v .who { display: block; }
.pol-v .note { margin: 0; }
.pol-v .note > div { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-2); }
.pol-v .note p { margin: 0; }
.pol-state { font-weight: var(--w-medium); }
.pol-state.on { color: var(--good); }
.pol-sub, .pol-none { color: var(--ink-2); }
.pol-a { display: flex; align-items: center; justify-content: flex-end; min-height: var(--h-md); }
.toggle.ro { opacity: .5; cursor: not-allowed; }
.choices.two { grid-template-columns: 1fr 1fr; }
.choices.life { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choices.life .choice.custom { grid-column: 1 / -1; }
.choice.custom > span { display: flex; flex-direction: column; gap: var(--s-2); flex: 1; }
.choice .days { gap: var(--s-2); }
.choice .days .input { width: 96px; height: var(--h-sm); }
/* two provider columns: a rate line ("0.0313 credits per agent-hour") fits on one line without breaking "agent-hour" */
.model-pick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); padding: var(--s-1) 0; transition: opacity .2s; }
.model-pick[disabled] { opacity: .45; }
.mp-g { display: flex; flex-direction: column; gap: var(--s-2); }

/* audit */
.au-filters { display: flex; flex-wrap: wrap; gap: var(--s-2); padding: var(--s-2); margin-bottom: var(--s-4); align-items: center; }
.au-filters select.input { width: auto; min-width: 0; max-width: 160px; }
.au-filters [hidden] { display: none; }
.au-filters [data-clear] { margin-left: auto; }
.au-q { position: relative; flex: 1 1 150px; min-width: 150px; }
.au-q .i { position: absolute; left: var(--s-3); top: var(--s-2); color: var(--ink-3); pointer-events: none; }
.au-q .input { padding-left: var(--s-8); }
.au-date { display: inline-flex; align-items: center; gap: var(--s-2); font: var(--f-small); color: var(--ink-3); }
.au-date .input { width: 130px; padding: 0 var(--s-2); }
.au-date > span { flex: none; white-space: nowrap; }
.au-dates { display: contents; } /* the two date fields; a grid at 760 (below) */
.au-panel { padding: var(--s-1) var(--s-2) var(--s-2); transition: opacity .15s; }
.au-panel.busy-list { opacity: .55; }
.ev-day { margin: 0; padding: var(--s-3) var(--s-3) var(--s-1); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.ev-list { list-style: none; margin: 0; padding: 0; }
.ev {
  display: grid; grid-template-columns: 26px minmax(0, 1fr) auto 76px; gap: var(--s-3); align-items: center; width: 100%; text-align: left;
  border: 0; background: none; padding: var(--s-2) var(--s-3); border-radius: var(--r-m); color: var(--ink);
}
.ev:hover { background: var(--hover); }
.ev.sel { background: var(--sel); }
.ev-a { font: var(--f-small); color: var(--ink-3); white-space: nowrap; }
.ev time { font: var(--f-small); color: var(--ink-3); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.au-more { display: flex; justify-content: center; padding: var(--s-3) 0 var(--s-2); }
.au-end { text-align: center; font: var(--f-small); color: var(--ink-3); margin: var(--s-3) 0 var(--s-2); }
.tbl.diff td { white-space: normal; padding-top: var(--s-2); padding-bottom: var(--s-2); }
.tbl.diff td.was { color: var(--ink-3); text-decoration: line-through; text-decoration-color: var(--ink-4); }
.tbl.diff td.now { font-weight: var(--w-medium); }
dl.kv dd.ua { font: var(--f-small); color: var(--ink-2); }
dl.kv dd code { color: var(--ink-2); }

@media (max-width: 1080px) {
  .roles-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .role-card:nth-child(4) { border-left: 0; }
  .role-card:nth-child(n+4) { border-top: 1px solid var(--line); }
}
@media (max-width: 760px) {
  .roles-pick, .choices.two { grid-template-columns: 1fr; }
  .choices.life { grid-template-columns: 1fr 1fr; }
  .model-pick { grid-template-columns: 1fr; }
  .roles-list { grid-template-columns: 1fr; }
  .role-card { border-left: 0; border-top: 1px solid var(--line); }
  .role-card:first-child { border-top: 0; }
  .role-card:nth-child(4) { border-top: 1px solid var(--line); }
  .pol-row { grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-3); padding: var(--s-3) var(--s-4); }
  .pol-row .pol-t { grid-column: 1 / -1; }
  .au-filters select.input { flex: 1 1 calc(50% - var(--s-1)); max-width: none; min-width: 0; }
  .au-q { flex-basis: 100%; }
  /* From and To share one label column, so their fields are one width */
  .au-dates { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--s-2); align-items: center; flex: 1 1 100%; }
  .au-date { display: contents; }
  .au-date .input { width: 100%; min-width: 0; }
  .ev { grid-template-columns: 26px minmax(0, 1fr) auto; gap: var(--s-3); }
  .person .cell-sub { max-width: 150px; }
  select.role-sel { min-width: 104px; }
  .tbl.members .role-cell .cell-sub { display: none; }
  #p-invites .row-actions { flex-direction: column; align-items: flex-end; gap: 0; }
  .tbl.matrix .c { width: 64px; }
  .tbl.matrix th[scope="row"] { min-width: 180px; position: sticky; left: 0; background: var(--panel); z-index: 1; }
}
