/* Users (Access) — same desk as Sites / Purchase orders. Tokens stay in main.css. */

.hub-main:has(#users-panel:not([hidden])) {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.hub-main:has(#users-panel:not([hidden])) > .subnav {
  flex: 0 0 auto;
}

.hub-main:has(#users-panel:not([hidden])) > .stage {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

#users-panel:not([hidden]) {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.users-screen {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  gap: 6px;
}

.users-screen > .list-head,
.users-screen > .error,
.users-screen > .due,
.users-screen > .account-ok,
.users-screen > .users-tabs {
  flex: 0 0 auto;
  margin: 0;
}

.users-screen > .users-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0 0 2px;
}

#users-panel .ord-po-workspace {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  max-height: none;
}

#users-panel .ord-po-detail-pane {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#users-panel .ord-po-layout,
#users-panel .ord-po-list,
#users-panel .ord-po-detail-pane {
  min-width: 0;
  min-height: 0;
}

#users-panel .ord-po-list {
  overflow: auto;
}

#users-panel .ord-po-table {
  display: grid;
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  min-height: 0;
  align-content: start;
  overflow: auto;
}

#users-panel .cat-list-sticky {
  position: sticky;
  top: 0;
  z-index: 3;
  align-self: start;
  background: var(--surface-2);
  width: max-content;
  min-width: 100%;
}

#users-panel .cat-list-sticky .ord-po-list-tools,
#users-panel .cat-list-sticky .ord-po-filters {
  position: static;
  background: var(--surface-2);
}

#users-panel .ord-po-filters,
#users-panel .ord-po-row {
  width: 100%;
  min-width: var(--ord-po-min, 0px);
}

#users-panel .ord-po-filters input {
  height: var(--list-row-height);
  min-height: var(--list-row-height);
  max-height: var(--list-row-height);
  padding: 0 12px 0 6px;
  font-size: 0.8rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
  box-sizing: border-box;
}

#users-panel .ord-po-filters .ord-sort-head {
  display: block;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#users-panel .ord-po-row,
#users-panel .ord-po-row .ord-po-col {
  font-size: 0.96rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
}

#users-panel .ord-po-row .ord-po-col,
#users-panel .ord-po-row .ord-po-col strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#users-panel .ord-po-row .ord-po-col strong {
  display: block;
  font-weight: 600;
}

#users-panel .ord-po-row .ord-po-col:has(.ord-pill) {
  display: flex;
  align-items: center;
  justify-content: center;
}

#users-panel .ord-po-row .ord-pill {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

#users-panel .ord-po-row.is-inactive {
  opacity: 0.6;
}

#users-panel .users-detail {
  padding: var(--nav-gap) var(--nav-gap) var(--nav-gap) 0;
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  align-content: start;
  box-sizing: border-box;
  background: var(--bg);
  gap: var(--nav-gap);
}

#users-panel .ord-po-detail-empty {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

#users-panel .users-detail .ord-po-detail-head {
  margin-bottom: 0;
  gap: 8px;
}

#users-panel .users-detail .ord-po-number {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--brand);
}

#users-panel .users-detail .ord-po-detail-sub {
  margin: 2px 0 0;
  font-size: 0.78rem;
}

.users-form {
  display: grid;
  gap: var(--nav-gap);
  margin-top: 0;
}

/* Kill UA fieldset frames and section cards so detail content is flush. */
#users-panel .users-form > fieldset,
#users-panel .users-fields fieldset.field {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
  background: transparent;
}

#users-panel .users-section {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
  background: var(--surface);
  border-radius: var(--radius);
}

.users-section-title {
  margin: 0 0 8px;
  padding: 0;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: transparent;
  border: 0;
}

.users-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
  padding: 0;
}

.users-fields .field {
  min-width: 0;
  margin: 0;
}

.users-fields .field.is-wide {
  grid-column: 1 / -1;
}

.users-fields .field span,
.users-fields fieldset.field > span {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}

.users-fields select,
.users-fields input[type="text"],
.users-fields input[type="email"] {
  width: 100%;
  min-height: 34px;
  height: 34px;
  padding: 8px 10px;
  font-size: 0.92rem;
}

.users-fields .check-grid {
  margin-top: 2px;
}

.users-role-perms > span {
  margin-bottom: 6px;
}

.users-perm-nav {
  display: grid;
  gap: 8px;
  margin-top: 4px;
}

.users-perm-nav-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
}

.users-perm-nav-tools .linkish {
  font-size: 0.78rem;
}

.users-perm-accordion {
  --users-perm-ticks-w: calc(2.35rem + 2.15rem + 18px + 18px + 24px);
  border: 1px solid var(--line);
  background: var(--surface);
}

.users-perm-accordion-head-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--users-perm-ticks-w);
  gap: 12px;
  align-items: center;
  padding: 8px 12px;
  background: var(--surface-2);
}

.users-perm-accordion-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 0;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.users-perm-accordion-head-row:hover,
.users-perm-accordion-head:focus-visible {
  background: color-mix(in srgb, var(--brand-soft) 55%, var(--surface-2));
}

.users-perm-head-ticks,
.users-perm-item-ticks {
  display: grid;
  grid-template-columns: 2.35rem 18px 2.15rem 18px;
  column-gap: 8px;
  align-items: center;
  justify-items: center;
  width: var(--users-perm-ticks-w);
}

.users-perm-accordion-head.has-tip {
  position: relative;
}

.users-perm-accordion-head.has-tip::after {
  content: attr(data-tip);
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  z-index: 6;
  max-width: min(280px, 70vw);
  padding: 6px 8px;
  border: 1px solid var(--line);
  background: var(--ink);
  color: var(--surface);
  font-size: 0.74rem;
  font-weight: 400;
  line-height: 1.35;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 80ms ease, visibility 80ms ease;
}

.users-perm-accordion-head.has-tip:hover::after,
.users-perm-accordion-head.has-tip:focus-visible::after {
  opacity: 1;
  visibility: visible;
  transition-delay: 250ms;
}

.users-perm-accordion-title {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.users-perm-accordion-meta {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

.users-perm-accordion-chevron {
  font-size: 0.85rem;
  color: var(--muted);
}

.users-perm-accordion-body {
  display: grid;
  gap: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}

.users-perm-accordion-body > .users-perm-item .users-perm-area {
  padding-left: 16px;
}

.users-perm-accordion-body > .users-perm-item.is-nested .users-perm-area {
  padding-left: 32px;
}

.users-perm-sub {
  border: 1px solid var(--line);
  background: var(--bg);
}

.users-perm-sub-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 0;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.users-perm-sub-head:hover,
.users-perm-sub-head:focus-visible {
  background: color-mix(in srgb, var(--brand-soft) 40%, transparent);
}

.users-perm-sub-title {
  font-size: 0.84rem;
  font-weight: 650;
}

.users-perm-sub-body {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.users-perm-sub-body .users-perm-item:first-child {
  padding-top: 8px;
}

.users-perm-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--users-perm-ticks-w, calc(2.35rem + 2.15rem + 18px + 18px + 24px));
  gap: 12px;
  align-items: center;
  padding: 8px 12px;
}

.users-perm-item + .users-perm-item {
  border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}

.users-perm-item-copy {
  position: relative;
  min-width: 0;
}

.users-perm-area {
  display: block;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink);
}

/* Delayed tip (~250ms): common desktop hover delay. Hides quickly on leave. */
.users-perm-item-copy.has-tip::after {
  content: attr(data-tip);
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  z-index: 5;
  max-width: min(280px, 70vw);
  padding: 6px 8px;
  border: 1px solid var(--line);
  background: var(--ink);
  color: var(--surface);
  font-size: 0.74rem;
  font-weight: 400;
  line-height: 1.35;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 80ms ease, visibility 80ms ease;
}

.users-perm-item-copy.has-tip:hover::after,
.users-perm-item-copy.has-tip:focus-within::after {
  opacity: 1;
  visibility: visible;
  transition-delay: 250ms;
}



.users-perm-tick-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
}

.users-perm-tick-spacer {
  width: 18px;
  height: 18px;
}

.users-perm-nav.is-locked .users-perm-accordion-head {
  cursor: default;
}

.users-perm-item.is-gated {
  opacity: 0.45;
}

.users-perm-item.is-gated .users-perm-area,
.users-perm-item.is-gated .users-perm-tick-label {
  color: var(--muted);
}

.users-perm-item.is-edit-gated .users-perm-tick.is-gated {
  opacity: 0.45;
}

.users-perm-tick.is-gated {
  cursor: not-allowed;
}

.users-perm-tick {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  overflow: visible;
  cursor: pointer;
}

/* Invisible hit-target over the painted box. Keep pointer events so ticks toggle. */
#users-panel .users-perm-tick input[type="checkbox"],
.users-perm-tick input[type="checkbox"] {
  position: absolute !important;
  inset: 0 !important;
  z-index: 2;
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  opacity: 0 !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  cursor: inherit;
  pointer-events: auto !important;
}

#users-panel .users-perm-tick.is-locked input[type="checkbox"],
#users-panel .users-perm-tick.is-gated input[type="checkbox"],
.users-perm-tick.is-locked input[type="checkbox"],
.users-perm-tick.is-gated input[type="checkbox"] {
  pointer-events: none !important;
}

.users-perm-box {
  position: relative;
  z-index: 0;
  width: 16px;
  height: 16px;
  box-sizing: border-box;
  border: 1.5px solid var(--check-edge);
  border-radius: 3px;
  background: var(--check-fill);
  background-clip: padding-box;
  pointer-events: none;
  flex: 0 0 auto;
}

.users-perm-tick input:checked + .users-perm-box {
  background-color: var(--check-fill);
  border-color: var(--check-edge);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%231a1a1a' stroke-width='2.2' stroke-linecap='square' d='M3.5 8.2 6.6 11.2 12.5 4.8'/%3E%3C/svg%3E");
  background-size: 12px 12px;
  background-position: center;
  background-repeat: no-repeat;
}

.users-perm-tick.is-locked {
  cursor: default;
  opacity: 0.85;
}

.users-perm-tick.is-locked input:disabled + .users-perm-box {
  border-color: var(--check-edge);
  background: var(--check-fill);
  opacity: 0.72;
}

.users-perm-tick.is-locked input:disabled:checked + .users-perm-box {
  background-color: var(--check-fill);
  border-color: var(--check-edge);
  opacity: 0.72;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%231a1a1a' stroke-width='2.2' stroke-linecap='square' d='M3.5 8.2 6.6 11.2 12.5 4.8'/%3E%3C/svg%3E");
  background-size: 12px 12px;
  background-position: center;
  background-repeat: no-repeat;
}

.users-perm-na {
  color: var(--muted);
  font-size: 0.78rem;
}

.users-perm-nav.is-locked {
  opacity: 0.96;
}

.users-role-perms.is-owner-locked .users-perm-nav {
  opacity: 0.96;
}

.users-owner-lock-note {
  margin: 0 0 6px;
  font-size: 0.74rem;
}



#users-panel input[type="checkbox"]:disabled {
  cursor: default;
  opacity: 0.72;
  border-color: var(--check-edge);
  background-color: var(--check-fill);
}

#users-panel input[type="checkbox"]:disabled:checked {
  background-color: var(--check-fill);
  border-color: var(--check-edge);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%231a1a1a' stroke-width='2.2' stroke-linecap='square' d='M3.5 8.2 6.6 11.2 12.5 4.8'/%3E%3C/svg%3E");
  background-size: 12px 12px;
  background-position: center;
  background-repeat: no-repeat;
}



.users-fields .muted {
  margin: 4px 0 0;
  font-size: 0.74rem;
  text-transform: none;
  letter-spacing: 0;
}

.users-site-perm-hint {
  display: block;
  margin: 0 0 6px;
  font-size: 0.74rem;
}

.users-site-card-title {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.users-site-job {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.users-site-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.users-site-card {
  border: 1px solid var(--line);
  background: var(--bg);
  padding: 6px 8px;
  min-width: 0;
}

.users-site-card.is-home {
  border-color: color-mix(in srgb, var(--brand) 45%, var(--line));
  background: color-mix(in srgb, var(--brand-soft) 55%, var(--bg));
}

.users-site-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
  min-height: 22px;
}

.users-site-card-head strong {
  min-width: 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.users-site-card-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex: 0 0 auto;
}

.users-home-pick {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
  white-space: nowrap;
  cursor: pointer;
}

.users-site-card-actions .linkish {
  font-size: 0.72rem;
}

.users-site-roles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px 6px;
  margin-top: 0;
}

.users-site-roles .check-inline {
  gap: 4px;
  min-height: 0;
  padding: 1px 0;
  font-size: 0.74rem;
  line-height: 1.2;
}

/* Light grey tick boxes. Same fill when empty or ticked, so the square stays easy to see. */
#users-panel input[type="checkbox"],
#users-panel input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin: 0;
  flex: 0 0 auto;
  box-sizing: border-box;
  border: 1.5px solid var(--check-edge);
  background-color: var(--check-fill);
  background-image: none;
  color: var(--check-tick);
  vertical-align: middle;
  cursor: pointer;
  accent-color: var(--check-edge);
}

#users-panel input[type="checkbox"] {
  border-radius: 3px;
}

#users-panel input[type="radio"] {
  border-radius: 50%;
}

#users-panel input[type="checkbox"]:checked,
#users-panel input[type="radio"]:checked {
  background-color: var(--check-fill);
  border-color: var(--check-edge);
}

#users-panel input[type="checkbox"]:checked {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%231a1a1a' stroke-width='2.2' stroke-linecap='square' d='M3.5 8.2 6.6 11.2 12.5 4.8'/%3E%3C/svg%3E");
  background-size: 12px 12px;
  background-position: center;
  background-repeat: no-repeat;
}

#users-panel input[type="radio"]:checked {
  background-image: radial-gradient(circle, #1a1a1a 0 35%, transparent 37%);
}

#users-panel input[type="checkbox"]:focus-visible,
#users-panel input[type="radio"]:focus-visible {
  outline: 2px solid var(--check-edge);
  outline-offset: 1px;
}

.users-home-pick input {
  width: 16px;
  height: 16px;
}

.users-site-roles .check-inline input {
  width: 16px;
  height: 16px;
}

.users-site-add {
  margin-top: 6px;
}

.users-site-add select {
  width: 100%;
  max-width: 240px;
  min-height: 34px;
  height: 34px;
  padding: 8px 10px;
  font-size: 0.92rem;
}

@media (max-width: 1180px) {
  .users-site-roles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1100px) {
  .users-site-cards {
    grid-template-columns: 1fr;
  }

  .users-site-roles {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.users-invite-box {
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  display: grid;
  gap: 8px;
}

.users-invite-box .invite-url {
  width: 100%;
  font-size: 0.8rem;
}

.users-warn {
  margin: 0;
  padding: 0 0 1rem;
  color: var(--ink);
}

@media (max-width: 980px) {
  .hub-main:has(#users-panel:not([hidden])),
  .hub-main:has(#users-panel:not([hidden])) > .stage {
    overflow: auto;
  }

  #users-panel:not([hidden]),
  #users-panel .users-screen,
  #users-panel .ord-po-workspace,
  #users-panel .ord-po-layout {
    height: auto;
    overflow: visible;
  }

  #users-panel .ord-po-list {
    max-height: 42vh;
    overflow: auto;
  }

  #users-panel .ord-po-detail-pane {
    display: block;
    overflow: visible;
  }

  #users-panel .users-detail {
    height: auto;
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 720px) {
  .users-fields {
    grid-template-columns: 1fr;
  }
}
