/* Tokens, chrome and type are lifted from admin/wa-flow/index.blade.php so this
   page reads as the same product as Interactive Flows. Keep them in sync. */
.acc {
    --teal: #075e54;
    --green: #25d366;
    --green-700: #14a44d;
    --ink: #0c211d;
    --muted: #6b7c79;
    --faint: #9aa8a4;
    --line: #e7edea;
    --surface: #fff;
    --surface-2: #f7faf9;
    --canvas: #eef3f1;
    --warn-bg: #fff8ec;
    --warn-line: #f1e2c4;
    --warn-ink: #8a5a00;
    --r-pill: 999px;
    font-family: "Plus Jakarta Sans", system-ui, sans-serif;
    color: var(--ink);
    background: var(--canvas);
    min-height: calc(100vh - 60px);
    padding: 28px 30px;
    -webkit-font-smoothing: antialiased;
}

/* hero */
/* The list is only three columns, so on a wide monitor an uncapped 1fr strands
   the dates against the far edge. Cap it at roughly the content width. */
.acc-hero, .acc-card { max-width: 1180px; }
.acc-hero { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.acc-hero-titles { display: flex; align-items: center; gap: 14px; }
.acc-logo {
    width: 46px; height: 46px; border-radius: 13px; flex: none;
    display: grid; place-items: center; color: #fff; font-size: 20px;
    background: linear-gradient(145deg, var(--green), var(--teal));
    box-shadow: 0 6px 18px rgba(7, 94, 84, .25);
}
.acc-h1 {
    font-family: "Bricolage Grotesque", sans-serif; font-weight: 700;
    font-size: 27px; letter-spacing: -.02em; margin: 0; color: var(--ink);
}
.acc-sub { color: var(--muted); font-size: 13.5px; margin-top: 2px; }

/* card */
.acc-card {
    background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
    overflow: hidden; box-shadow: 0 1px 3px rgba(10, 40, 35, .05);
}
.acc-card + .acc-card { margin-top: 18px; }

/* rows */
.acc-row {
    /* Role needs room for the select control; Granted on only ever holds a short date. */
    display: grid; grid-template-columns: 1fr 158px 128px 148px; align-items: center;
    gap: 16px; padding: 16px 22px; border-bottom: 1px solid var(--line);
    transition: background .12s;
}
.acc-row:last-child { border-bottom: none; }
.acc-row.head {
    background: var(--surface-2); font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .08em; color: var(--faint); padding: 12px 22px;
}
.acc-row.item:hover { background: var(--surface-2); }
/* Same specificity as .acc-row.head, declared after it, so the single-column
   override actually lands. */
.acc-row.acc-head-single { grid-template-columns: 1fr; }

.acc-name { display: flex; align-items: center; gap: 12px; min-width: 0; }
.acc-avatar {
    width: 38px; height: 38px; border-radius: 11px; flex: none;
    display: grid; place-items: center; background: rgba(7, 94, 84, .08);
    color: var(--teal); font-size: 13px; font-weight: 700;
}
.acc-name-body { min-width: 0; }
.acc-name-text { display: flex; align-items: center; gap: 9px; min-width: 0; }
.acc-name-label {
    font-weight: 600; font-size: 15px; color: var(--ink);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.acc-name-meta {
    font-size: 11.5px; color: var(--faint);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Outline tag = what kind of member this is, matching the flows page's
   tag-vs-pill split (filled pills there mean state, outlines mean kind). */
.acc-tag {
    display: inline-flex; align-items: center; gap: 7px; flex: none;
    font-size: 12px; font-weight: 700; padding: 4px 11px;
    border-radius: var(--r-pill); border: 1px solid transparent;
}
.acc-tag.owner { color: var(--green-700); background: rgba(37, 211, 102, .10); border-color: rgba(37, 211, 102, .32); }

.acc-cell { font-size: 13.5px; color: var(--muted); min-width: 0; }
.acc-cell.unknown { color: var(--faint); }

/* grant form */
.acc-form { padding: 20px 22px; }
.acc-select {
    display: block; width: 100%; max-width: 460px;
    font-family: inherit; font-size: 14.5px; color: var(--ink);
    background-color: var(--surface); border: 1px solid var(--line);
    border-radius: 12px; padding: 11px 38px 11px 14px; cursor: pointer;
    appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' stroke='%236b7c79' stroke-width='1.75' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center;
}
.acc-select:hover { border-color: #d4e0dc; }
.acc-select:focus-visible, .acc-grant:focus-visible { outline: 2px solid var(--green-700); outline-offset: 2px; }

.acc-grant {
    display: inline-flex; align-items: center; gap: 8px; border: none;
    background: var(--green); color: #04231a; font-family: inherit;
    font-weight: 700; font-size: 14.5px; border-radius: var(--r-pill);
    padding: 12px 22px; cursor: pointer;
    box-shadow: 0 3px 12px rgba(37, 211, 102, .4);
    transition: transform .08s, background .15s;
}
.acc-grant:hover:not(:disabled) { background: var(--green-700); color: #fff; }
.acc-grant:active:not(:disabled) { transform: translateY(1px); }
.acc-grant:disabled { background: #dfe7e4; color: var(--muted); box-shadow: none; cursor: not-allowed; }
.acc-actions { margin-top: 18px; }

.acc-alert {
    background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-ink);
    border-radius: 12px; padding: 12px 16px; font-size: 13.5px; line-height: 1.5;
    margin-top: 16px; max-width: 560px;
}
.acc-alert.danger { background: #fdeeee; border-color: #f3cfcf; color: #9b2c2c; }

/* empty + loading */
.acc-empty { text-align: center; padding: 44px 24px; }
.acc-empty-icon {
    width: 72px; height: 72px; border-radius: 22px; margin: 0 auto 18px;
    display: grid; place-items: center; font-size: 28px;
    color: var(--teal); background: rgba(7, 94, 84, .07);
}
.acc-empty-title { font-family: "Bricolage Grotesque", sans-serif; font-weight: 700; font-size: 19px; margin-bottom: 6px; }
.acc-empty-sub { color: var(--muted); font-size: 14px; }
.acc-loading { padding: 40px 22px; text-align: center; color: var(--muted); font-size: 14px; }

@media (max-width: 820px) {
    .acc { padding: 20px 16px; }
    .acc-row { grid-template-columns: 1fr; gap: 10px; }
    /* Collapse the table header into per-cell labels, but keep the card
       headings (which are the same element) visible. */
    .acc-row.head:not(.acc-head-single) { display: none; }
    .acc-cell::before {
        content: attr(data-label) " "; font-size: 10.5px; font-weight: 700;
        text-transform: uppercase; letter-spacing: .08em; color: var(--faint);
    }
    .acc-hero { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
    .acc-row, .acc-grant, .acc-select { transition: none; }
}

/* The per-member role picker: same control as .acc-select, sized to sit inside a
   table row rather than on a form. */
.acc-role-select {
    width: auto; max-width: none; min-width: 132px;
    font-size: 13.5px; padding: 7px 32px 7px 12px;
    background-position: right 11px center;
}

/* ---- Role matrix -------------------------------------------------------
   Areas x roles, one pill per cell cycling No access -> View -> Edit. The three
   levels borrow the flows page's own three pill treatments, so filled means the
   highest level, outline means present, muted means absent. */
.acc-mx-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.acc-mx-scope {
    display: inline-flex; align-items: center; gap: 6px;
    color: var(--warn-ink); background: var(--warn-bg); border: 1px solid var(--warn-line);
    border-radius: var(--r-pill); padding: 3px 11px;
    font-size: 10px; letter-spacing: .07em;
}

.acc-mx-wrap { overflow-x: auto; padding: 4px 22px 0; }
.acc-mx { width: 100%; border-collapse: collapse; }

.acc-mx thead th {
    font-family: "Plus Jakarta Sans", system-ui, sans-serif;
    font-size: 13px; font-weight: 700; color: var(--ink);
    text-align: center; padding: 14px 8px 12px; white-space: nowrap;
    border-bottom: 1px solid var(--line);
}
.acc-mx thead th.acc-mx-area-h {
    text-align: left; font-size: 10.5px; font-weight: 700; color: var(--faint);
    text-transform: uppercase; letter-spacing: .08em;
}
.acc-mx-count { display: block; font-size: 10.5px; font-weight: 500; color: var(--faint); margin-top: 2px; }

.acc-mx tbody th.acc-mx-area {
    text-align: left; font-weight: 600; font-size: 14px; color: var(--ink);
    padding: 9px 18px 9px 0; white-space: nowrap;
}
.acc-mx-ro {
    display: block; font-size: 10.5px; font-weight: 500; color: var(--faint);
    text-transform: uppercase; letter-spacing: .07em; margin-top: 1px;
}
.acc-mx tbody tr + tr th, .acc-mx tbody tr + tr td { border-top: 1px solid var(--line); }
.acc-mx tbody td { text-align: center; padding: 9px 8px; }

.acc-mx-cell {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-width: 84px; font-family: inherit; font-size: 12px; font-weight: 700;
    border-radius: var(--r-pill); padding: 5px 13px; cursor: pointer;
    border: 1px solid transparent; background: transparent;
    transition: background .12s, border-color .12s, color .12s;
}
.acc-mx-cell.is-none { color: var(--faint); background: #eef1f0; }
.acc-mx-cell.is-view { color: var(--muted); background: transparent; border-color: var(--line); }
.acc-mx-cell.is-edit { color: var(--green-700); background: rgba(37, 211, 102, .14); }
.acc-mx-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.acc-mx-dash { font-weight: 700; }

.acc-mx-cell:hover:not(:disabled) { border-color: var(--green); color: var(--green-700); }
.acc-mx-cell:focus-visible { outline: 2px solid var(--green-700); outline-offset: 2px; }
.acc-mx-cell:disabled { cursor: not-allowed; }
.acc-mx-cell.is-locked { color: var(--teal); background: rgba(7, 94, 84, .08); }
.acc-mx-lockicon { font-size: 9px; opacity: .75; }

/* Legend pills are labels, not controls — strip the affordances. */
.acc-mx-cell.as-key { min-width: 0; cursor: default; pointer-events: none; }

.acc-mx-foot { border-top: 1px solid var(--line); background: var(--surface-2); padding: 14px 22px; }
.acc-mx-legend { display: flex; flex-wrap: wrap; gap: 18px; margin-bottom: 14px; }
.acc-mx-key { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }

.acc-mx-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.acc-mx-pending { font-size: 13px; color: var(--ink); font-weight: 600; }
.acc-mx-pending.is-clean { color: var(--faint); font-weight: 500; }
.acc-mx-acts { display: flex; align-items: center; gap: 16px; }

.acc-reset {
    background: none; border: 0; padding: 0; font-family: inherit; font-size: 13.5px;
    color: var(--muted); cursor: pointer; border-bottom: 1px solid var(--line);
}
.acc-reset:hover:not(:disabled) { color: var(--teal); border-color: var(--teal); }
.acc-reset:focus-visible { outline: 2px solid var(--green-700); outline-offset: 3px; }
.acc-reset:disabled { color: var(--faint); cursor: not-allowed; border-color: transparent; }

@media (max-width: 820px) {
    .acc-mx-head { flex-direction: column; align-items: flex-start; gap: 8px; }
    .acc-mx-wrap { padding: 4px 14px 0; }
    .acc-mx-cell { min-width: 72px; padding: 5px 10px; }
    .acc-mx tbody th.acc-mx-area { font-size: 13px; padding-right: 12px; }
    .acc-mx-bar { align-items: stretch; }
}

@media (prefers-reduced-motion: reduce) {
    .acc-mx-cell { transition: none; }
}

/* ---- Grant access -----------------------------------------------------
   The controls live inside the sentence they complete. Two stacked, unlabelled
   dropdowns left "Editor" floating free of what it applied to; read inline, the
   sentence is the label — and it uses the width the old form wasted. */
.acc-sentence {
    display: flex; align-items: center; flex-wrap: wrap; gap: 9px;
    margin: 0 0 18px; font-size: 15.5px; color: var(--ink); line-height: 1.6;
}
.acc-inline {
    display: inline-block; width: auto; max-width: 100%;
    font-size: 14.5px; padding: 8px 34px 8px 13px;
    background-position: right 12px center;
}
/* Person options carry name + email, so cap the control instead of letting it
   stretch the sentence off the card. */
.acc-inline.is-person { width: 268px; }
.acc-inline.is-role { width: 132px; }

/* What the chosen role actually reaches, in the matrix's own level chips so the
   two cards share one vocabulary. Derived live from the matrix. */
.acc-reach {
    border: 1px solid var(--line); border-radius: 14px;
    background: var(--surface-2); padding: 14px 16px; margin-bottom: 18px;
    max-width: 720px;
}
.acc-reach-label {
    font-size: 10.5px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .08em; color: var(--faint); margin-bottom: 10px;
}
.acc-reach-line {
    display: flex; align-items: baseline; gap: 10px;
    font-size: 13.5px; color: var(--ink); line-height: 1.5;
}
.acc-reach-line + .acc-reach-line { margin-top: 7px; }
.acc-reach-line.is-muted { color: var(--muted); }
.acc-reach-line > .acc-mx-cell { flex: none; }

.acc-grant-bar { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
/* A reserved slot, not a conditional block: choosing a person must not shove the
   button down the page. */
.acc-grant-note { flex: 1 1 280px; min-height: 20px; font-size: 13px; line-height: 1.5; }
.acc-note-hint { color: var(--faint); }
.acc-note-warn { color: var(--warn-ink); }
.acc-note-warn strong { font-weight: 700; }

@media (max-width: 620px) {
    .acc-inline.is-person, .acc-inline.is-role { width: 100%; }
    .acc-sentence { gap: 7px; }
}

/* ---- Access history ----------------------------------------------------
   A feed, not a table: the content is a sequence in time, so the rows carry no
   column structure to sort away. The left rail reads as a timeline. */
.acc-log { list-style: none; margin: 0; padding: 0; }
.acc-log-row {
    display: grid; grid-template-columns: 34px 1fr auto;
    align-items: baseline; gap: 14px;
    padding: 14px 22px; border-bottom: 1px solid var(--line);
}
.acc-log-row:last-child { border-bottom: none; }

.acc-log-mark {
    grid-row: span 1; align-self: center;
    width: 34px; height: 34px; border-radius: 11px; flex: none;
    display: grid; place-items: center; font-size: 12px;
    color: var(--teal); background: rgba(7, 94, 84, .08);
}
/* App-wide events are marked, not merely tinted — a matrix edit must never read
   as though it were scoped to this channel. */
.acc-log-mark.is-matrix { color: var(--warn-ink); background: var(--warn-bg); }

.acc-log-what { font-size: 14px; line-height: 1.55; color: var(--muted); }
.acc-log-what strong { color: var(--ink); font-weight: 600; }

.acc-log-role {
    display: inline-flex; align-items: center;
    font-size: 12px; font-weight: 700; padding: 2px 10px;
    border-radius: var(--r-pill);
    color: var(--green-700); background: rgba(37, 211, 102, .14);
}
/* The role they left behind: present, but plainly not the current one. */
.acc-log-role.is-was { color: var(--faint); background: #eef1f0; }
.acc-log-arrow { font-size: 9px; color: var(--faint); margin: 0 6px; }

.acc-log-cells {
    display: inline-flex; align-items: center;
    font-size: 12px; font-weight: 700; padding: 2px 10px; margin-left: 8px;
    border-radius: var(--r-pill); color: var(--muted);
    border: 1px solid var(--line);
}
.acc-log-scope { margin-left: 8px; vertical-align: middle; }

.acc-log-when { font-size: 12.5px; color: var(--faint); white-space: nowrap; }

@media (max-width: 620px) {
    .acc-log-row { grid-template-columns: 34px 1fr; row-gap: 6px; }
    .acc-log-when { grid-column: 2; }
}

/* ---- Tabs --------------------------------------------------------------
   A segmented control sitting ON the canvas, so the active tab reads as the
   card's own edge lifting off the background. Underlined tabs would have been
   the default answer; this page is built from pills, so its navigation is too. */
.acc-tabs {
    display: inline-flex; align-items: center; gap: 4px;
    background: rgba(7, 94, 84, .06); border-radius: var(--r-pill);
    padding: 4px; margin-bottom: 18px;
}
.acc-tab {
    display: inline-flex; align-items: center; gap: 8px;
    border: none; background: transparent; cursor: pointer;
    font-family: inherit; font-size: 13.5px; font-weight: 700;
    color: var(--muted); border-radius: var(--r-pill); padding: 9px 18px;
    transition: background .14s, color .14s;
}
.acc-tab:hover:not(.is-on) { color: var(--teal); }
.acc-tab.is-on {
    background: var(--surface); color: var(--ink);
    box-shadow: 0 1px 3px rgba(10, 40, 35, .10);
}
.acc-tab:focus-visible { outline: 2px solid var(--green-700); outline-offset: 2px; }

/* The count is a fact, not a badge: quiet until its tab is active. */
.acc-tab-n {
    font-size: 11.5px; font-weight: 700; color: var(--faint);
    background: rgba(7, 94, 84, .07); border-radius: var(--r-pill);
    padding: 1px 8px; min-width: 22px; text-align: center;
}
.acc-tab.is-on .acc-tab-n { color: var(--green-700); background: rgba(37, 211, 102, .14); }

@media (max-width: 620px) {
    .acc-tabs { display: flex; width: 100%; }
    .acc-tab { flex: 1; justify-content: center; padding: 9px 10px; }
}

@media (prefers-reduced-motion: reduce) {
    .acc-tab { transition: none; }
}

/* ---- New user ----------------------------------------------------------
   Four short facts, so two columns rather than a stack that pushes the roles
   below the fold. The inputs borrow the select's shape so the form reads as one
   control set. */
.acc-fields {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 20px; max-width: 720px; margin-bottom: 22px;
}
.acc-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.acc-field-label {
    font-size: 10.5px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .08em; color: var(--faint);
}
.acc-input {
    width: 100%; font-family: inherit; font-size: 14.5px; color: var(--ink);
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 12px; padding: 11px 14px;
}
.acc-input:hover { border-color: #d4e0dc; }
.acc-input:focus-visible { outline: 2px solid var(--green-700); outline-offset: 2px; }
.acc-input.is-short { max-width: 140px; }

.acc-field-hint { font-size: 12px; color: var(--faint); line-height: 1.4; }
.acc-field-err { font-size: 12px; color: #9b2c2c; line-height: 1.4; }

@media (max-width: 620px) {
    .acc-fields { grid-template-columns: minmax(0, 1fr); }
}
