/* Settings › Mailbox access (B-085, settings-mailboxes.js). Colours via tokens.css plus the table tokens below.
   UX-112: 28px/500 title, grants in a table (48px header row), row actions on hover/focus, 13px field errors. */
:root {
  --mbx-th-bg: #f5f5f7;   /* the table's header row */
  --mbx-th-h: 48px;
}
.settings-page.mbx-page { max-width: 820px; display: flex; flex-direction: column; gap: var(--sp-6); }
.mbx-page .settings-title { margin-bottom: 0; }
.mbx-page .settings-title.mbx-title { font-size: 28px; line-height: 36px; font-weight: 500; }
.mbx-page .field-error { font-size: 13px; line-height: 18px; }
.mbx-page .input.is-invalid, .mbx-page .select-trigger.is-invalid { border: 1px solid var(--red); }
.mbx-page .input.is-invalid:focus, .mbx-page .select-trigger.is-invalid:focus-visible { border-color: var(--red); }
.mbx-send-label { color: var(--text); font-size: var(--fs-md); font-weight: var(--fw-regular); }
.mbx-intro { margin: calc(-1 * var(--sp-4)) 0 0; color: var(--text-2); font-size: var(--fs-md); line-height: var(--lh-md); max-width: 640px; }

.mbx-add-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: var(--sp-5) var(--sp-6); align-items: start; }
.mbx-add-grid .settings-field { max-width: none; }
.mbx-add-grid .select-trigger { width: 100%; }
.mbx-add-send { margin-top: 30px; white-space: nowrap; }
.mbx-add-card .btn .ic, .mbx-add-card .btn svg { width: 16px; height: 16px; display: block; }
.mbx-add-card .btn { display: inline-flex; align-items: center; gap: var(--sp-3); }

.mbx-list { display: flex; flex-direction: column; gap: var(--sp-6); }
.settings-card.mbx-group { gap: var(--sp-4); padding: var(--sp-5) var(--sp-6); animation: mbx-in var(--t-med) var(--ease-enter); }

/* ---- Grants table (admin) ---- */
.mbx-table-wrap {
  overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--bg-surface);
  animation: mbx-in var(--t-med) var(--ease-enter);
}
.mbx-table { width: 100%; border-collapse: collapse; font-size: var(--fs-md); color: var(--text); }
.mbx-table th {
  height: var(--mbx-th-h); padding: 0 var(--sp-6); background: var(--mbx-th-bg); border-bottom: 1px solid var(--border);
  color: var(--text-2); font-size: var(--fs-sm); font-weight: var(--fw-semibold); text-align: left; white-space: nowrap;
}
.mbx-table th.mbx-th-send { width: 160px; }
.mbx-table th.mbx-th-act { width: 56px; }
.mbx-table td { height: 52px; padding: var(--sp-3) var(--sp-6); border-bottom: 1px solid var(--border); vertical-align: middle; }
.mbx-table tbody:last-child tr:last-child td { border-bottom: 0; }
.mbx-table tr.mbx-row { transition: background var(--t-fast) var(--ease); }
.mbx-table tr.mbx-row:hover, .mbx-table tr.mbx-row:focus-within { background: var(--bg-hover); }
.mbx-box { display: flex; align-items: center; gap: var(--sp-4); min-width: 0; }
.mbx-box-ic, .mbx-box-ic svg { width: 16px; height: 16px; display: block; flex: none; color: var(--text-2); }
.mbx-box-email { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 280px; }
.mbx-user { display: flex; align-items: center; gap: var(--sp-5); min-width: 0; }
.mbx-td-act { text-align: right; }
/* Row actions show on hover or keyboard focus; opacity keeps them in the tab order. */
.mbx-table .mbx-remove { opacity: 0; }
.mbx-table tr.mbx-row:hover .mbx-remove, .mbx-table tr.mbx-row:focus-within .mbx-remove { opacity: 1; }
.mbx-group-head { display: flex; align-items: center; gap: var(--sp-4); min-width: 0; }
.mbx-group-ic, .mbx-group-ic svg { width: 18px; height: 18px; display: block; flex: none; color: var(--text-2); }
.mbx-group-title {
  margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: var(--fs-lg); line-height: var(--lh-lg); font-weight: var(--fw-semibold);
}
.mbx-group-count { flex: none; margin-left: auto; color: var(--text-2); font-size: var(--fs-sm); }
.mbx-rows { display: flex; flex-direction: column; border-top: 1px solid var(--border); }
.mbx-rows .mbx-row {
  display: flex; align-items: center; gap: var(--sp-5); min-height: 52px; padding: var(--sp-3) var(--sp-2);
  border-bottom: 1px solid var(--border); transition: background var(--t-fast) var(--ease);
}
.mbx-rows .mbx-row:last-child { border-bottom: 0; }
.mbx-rows .mbx-row:hover { background: var(--bg-hover); }
.mbx-av { flex: none; width: 32px; height: 32px; font-size: var(--fs-sm); }
.mbx-who { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: var(--lh-md); }
.mbx-who-name, .mbx-who-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mbx-who-name { color: var(--text); font-weight: var(--fw-semibold); }
.mbx-who-email { color: var(--text-2); font-size: var(--fs-sm); line-height: var(--lh-sm); }
.mbx-send { flex: none; }
.mbx-send-ro { flex: none; color: var(--text-2); font-size: var(--fs-sm); }
.mbx-remove { flex: none; color: var(--text-2); opacity: .7; transition: opacity var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.mbx-row:hover .mbx-remove, .mbx-remove:focus-visible { opacity: 1; }
.mbx-remove:hover { color: var(--red); }
.mbx-remove .ic, .mbx-remove svg { width: 16px; height: 16px; display: block; }

.mbx-empty {
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-4); padding: var(--sp-9) var(--sp-7);
  border: 1px dashed var(--border-strong); border-radius: var(--r-lg); color: var(--text-2); text-align: center;
}
.mbx-empty-ic, .mbx-empty-ic svg { width: 36px; height: 36px; display: block; color: var(--text-muted); }

@keyframes mbx-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .settings-card.mbx-group, .mbx-table-wrap { animation: none; } }
@media (max-width: 720px) {
  .mbx-add-grid { grid-template-columns: 1fr; }
  .mbx-add-send { margin-top: 0; }
  .mbx-table th, .mbx-table td { padding: 0 var(--sp-4); }
  .mbx-table .mbx-remove { opacity: 1; }
}
