/* Accounts tab (static/admin_users.js).
 * Page tokens only (--surface, --text, ...), so the [data-theme="dark"]
 * switch needs nothing here. Monochrome: the only colour is the danger tone
 * on delete, blocked accounts and validation errors. */
#tab-admin, .au-overlay {
    --au-tint: color-mix(in srgb, var(--text) 6%, transparent);
    --au-tint-strong: color-mix(in srgb, var(--text) 12%, transparent);
}
#tab-admin { padding: 16px 22px; }

.au-icon { width: 16px; height: 16px; flex: none; }
.au-icon-sm { width: 14px; height: 14px; }

/* ---- Toolbar ---- */
.au-toolbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px;
    padding: 10px 12px; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.au-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; margin-right: 6px; }
.au-spacer { flex: 1; }
.au-meta { font-size: 12px; color: var(--text-secondary); }

.au-search {
    display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; min-width: 220px;
    color: var(--text-secondary); background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.au-search:focus-within { border-color: var(--text); }
.au-search input {
    flex: 1; min-width: 0; height: 100%; padding: 0; font: inherit; font-size: 13px;
    color: var(--text); background: transparent; border: none; outline: none;
}

.au-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 34px; padding: 0 14px; font: inherit; font-size: 13px; color: var(--text); cursor: pointer;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
    white-space: nowrap;
}
.au-btn:hover { background: var(--au-tint); }
.au-btn:disabled { opacity: .5; cursor: default; }
.au-btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.au-btn-primary { background: var(--text); color: var(--surface); border-color: var(--text); font-weight: 500; }
.au-btn-primary:hover { background: var(--text); opacity: .88; }

.au-icon-btn {
    display: inline-grid; place-items: center; width: 28px; height: 28px; padding: 0;
    color: var(--text-secondary); background: transparent; border: none; border-radius: 6px; cursor: pointer;
}
.au-icon-btn:hover { color: var(--text); background: var(--au-tint); }
.au-icon-btn.au-danger:hover { color: var(--danger); }

/* ---- Grid ---- */
.au-grid { height: calc(100vh - 210px); min-height: 360px; width: 100%; }
.au-user { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.au-avatar {
    display: inline-grid; place-items: center; width: 24px; height: 24px; flex: none;
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    border-radius: 50%; background: var(--au-tint-strong); color: var(--text);
}
.au-tag {
    display: inline-flex; align-items: center; gap: 4px; padding: 0 8px; line-height: 20px; font-size: 12px;
    border: 1px solid var(--border); border-radius: 999px; background: var(--au-tint); white-space: nowrap;
}
.au-tag-strong { background: var(--text); color: var(--surface); border-color: var(--text); }
.au-tag-muted { background: transparent; border-style: dashed; color: var(--text-secondary); }
.au-tag-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.au-cell-muted { color: var(--text-secondary); }
.au-actions { display: inline-flex; gap: 4px; align-items: center; height: 100%; }

/* ---- Modals ---- */
.au-modal { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.au-modal-lg { width: min(1180px, 96vw); height: min(860px, 92vh); max-height: 92vh; }
.au-modal-sm { width: min(420px, 94vw); }
.au-modal-head {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
    padding: 20px 24px 14px; border-bottom: 1px solid var(--border-light);
}
.au-modal h3 { margin: 0; font-size: 18px; }
.au-modal-sub { margin: 4px 0 0; font-size: 13px; color: var(--text-secondary); }
.au-modal-body { flex: 1; min-height: 0; overflow: auto; padding: 18px 24px; }
.au-modal-foot {
    display: flex; align-items: center; gap: 10px; padding: 14px 24px;
    border-top: 1px solid var(--border-light); background: var(--surface);
}
.au-modal-foot .au-meta { flex: 1; }

.au-cols { display: grid; grid-template-columns: minmax(300px, 360px) 1fr; gap: 24px; align-items: start; }
.au-col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

.au-section { display: flex; flex-direction: column; gap: 10px; }
.au-section-head { display: flex; align-items: center; gap: 8px; }
.au-section-title {
    font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-secondary);
}
.au-section-head .au-meta { margin-left: auto; }
.au-hint { margin: 0; font-size: 12px; color: var(--text-secondary); }
.au-hint:empty { display: none; }

.au-field { display: flex; flex-direction: column; gap: 6px; }
.au-label { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.au-input-wrap { position: relative; display: flex; }
.au-field input, .au-field select {
    width: 100%; height: 40px; padding: 0 12px; font: inherit; font-size: 14px; color: var(--text);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
    color-scheme: light dark;
}
.au-field input:disabled { color: var(--text-secondary); background: var(--au-tint); }
.au-input-wrap input { padding-right: 40px; }
.au-input-wrap .au-icon-btn { position: absolute; right: 6px; top: 6px; }
.au-field input:focus, .au-field select:focus { outline: none; border-color: var(--text); }
.au-field.invalid input { border-color: var(--danger); }

/* Role cards */
.au-roles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.au-role {
    display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; cursor: pointer;
    border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
}
.au-role:hover { background: var(--au-tint); }
.au-role input { position: absolute; opacity: 0; pointer-events: none; }
.au-role-name { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.au-role-desc { font-size: 11px; line-height: 1.35; color: var(--text-secondary); }
.au-role.active { border-color: var(--text); box-shadow: inset 0 0 0 1px var(--text); }
.au-role:focus-within { outline: 2px solid var(--au-tint-strong); outline-offset: 1px; }

/* Checkbox list (branches) */
.au-checklist {
    display: flex; flex-direction: column; max-height: 260px; overflow: auto; padding: 4px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.au-check {
    display: flex; align-items: center; gap: 8px; padding: 6px 8px; font-size: 13px; cursor: pointer; border-radius: 6px;
}
.au-check:hover { background: var(--au-tint); }
.au-check input, .au-chip input, .au-group-head input { margin: 0; accent-color: var(--text); }
.au-empty { padding: 12px; font-size: 12px; text-align: center; color: var(--text-secondary); }

/* Security notice */
.au-notice {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px; font-size: 12px;
    border: 1px solid var(--danger); border-radius: var(--radius-sm); color: var(--danger);
}
.au-notice span { flex: 1; }

/* Tab access groups */
.au-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.au-group { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.au-group-head {
    display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer;
    font-size: 13px; font-weight: 600; background: var(--au-tint);
}
.au-group-head .au-meta { margin-left: auto; font-weight: 400; }
.au-group-body { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px; }
.au-chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; font-size: 12px; cursor: pointer;
    border: 1px solid var(--border); border-radius: 999px; background: var(--surface); user-select: none;
}
.au-chip:hover { background: var(--au-tint); }
.au-chip.on { border-color: var(--text); font-weight: 500; }
.au-group[hidden], .au-chip[hidden], .au-check[hidden] { display: none; }

/* Reused /table/ filter tree (_renderUserBuildingTree): monochrome inside this modal. */
#au-form #au-tree { max-height: 320px; overflow: auto; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
#au-form #au-tree .pill:hover, #au-form #au-tree .b-toolbar button:hover { border-color: var(--text); }
#au-form #au-tree .pill input { accent-color: var(--text); }

@media (max-width: 900px) {
    .au-cols { grid-template-columns: 1fr; }
    .au-modal-lg { height: 94vh; }
}
@media (max-width: 700px) {
    #tab-admin { padding: 12px 16px; }
    .au-spacer { display: none; }
    .au-search { min-width: 0; flex: 1; }
    .au-roles { grid-template-columns: 1fr; }
    .au-modal-head, .au-modal-body, .au-modal-foot { padding-left: 16px; padding-right: 16px; }
}
