/* =========================================================
   Auth pages — login, password reset
   ========================================================= */

.auth-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--surface-canvas);
  padding: 24px 16px;
}

/* Floating flash above the card */
.auth-flash {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 280px;
  max-width: 480px;
  padding: 10px 16px;
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  font-weight: 500;
  z-index: 100;
  text-align: center;
}
.auth-flash--notice { background: var(--success-100); color: var(--success-700); }
.auth-flash--alert  { background: var(--danger-100);  color: var(--danger-700);  }

.auth-errors {
  background: var(--danger-100);
  color: var(--danger-700);
  border-radius: var(--r-md);
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: var(--text-sm);
}
.auth-error-list { margin: 0; padding-left: 18px; }

/* Card */
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 36px 32px;
  box-shadow: var(--shadow-md);
}

/* Logo */
.auth-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 32px;
}
.auth-logo__img {
  height: 72px;
  width: auto;
  max-width: 80%;
  object-fit: contain;
}

/* Brand */
.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}
.auth-brand__logo {
  width: 36px;
  height: 36px;
  background: var(--surface-nav);
  color: var(--nav-accent);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--text-lg);
}
.auth-brand__title {
  font-weight: 700;
  font-size: var(--text-lg);
  color: var(--ink-900);
  line-height: 1;
  white-space: nowrap;
}

/* Heading */
.auth-heading {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--ink-900);
  margin-bottom: 6px;
  line-height: var(--lh-snug);
}
.auth-subtext {
  font-size: var(--text-sm);
  color: var(--ink-500);
  margin-bottom: 20px;
}

/* Form */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 20px;
}
.auth-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.auth-field--row {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.auth-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-700);
}
.auth-label--inline {
  font-weight: 400;
  color: var(--ink-600);
  cursor: pointer;
  user-select: none;
}
.auth-label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.auth-input {
  width: 100%;
  box-sizing: border-box;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  font-size: var(--text-base);
  font-family: var(--font-sans);
  color: var(--ink-900);
  background: var(--paper-elev);
  outline: none;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.auth-input:focus {
  border-color: var(--accent-600);
  box-shadow: var(--shadow-focus);
}
.auth-checkbox {
  width: 15px;
  height: 15px;
  accent-color: var(--accent-600);
  cursor: pointer;
}
.auth-btn {
  height: 38px;
  background: var(--surface-nav);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  font-size: var(--text-base);
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background var(--dur-fast);
  margin-top: 4px;
}
.auth-btn:hover { background: var(--surface-nav-elev); }
.auth-btn:active { background: var(--surface-nav-hover); }

/* Field-level error */
.auth-input--error {
  border-color: var(--danger-500) !important;
  background: #fff8f8;
}
.auth-input--error:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18) !important;
}
.auth-field-error {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--danger-700);
  margin-top: 2px;
}

/* Inline alert inside the card */
.auth-alert {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: var(--danger-100);
  color: var(--danger-700);
  border: 1px solid #fca5a5;
  border-radius: var(--r-md);
  padding: 10px 12px;
  font-size: var(--text-sm);
  font-weight: 500;
  margin-top: 4px;
}

/* Links */
.auth-link {
  color: var(--accent-700);
  font-size: var(--text-sm);
  text-decoration: none;
}
.auth-link:hover { text-decoration: underline; }
.auth-link--sm { font-size: var(--text-xs); }

.auth-footer {
  margin-top: 20px;
  text-align: center;
  font-size: var(--text-sm);
  color: var(--ink-500);
}

/* ---- Search bar ---- */
.admin-search-bar {
  padding: 10px 20px;
  background: var(--paper-elev);
  border-bottom: 1px solid var(--border-subtle);
}
.admin-search-bar__input-wrap {
  position: relative;
  width: 100%;
}
.admin-search-bar__icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-400);
  pointer-events: none;
}
.admin-search-bar__input {
  width: 100%;
  height: 34px;
  padding: 0 32px 0 32px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  font-size: var(--text-base);
  font-family: var(--font-sans);
  color: var(--ink-900);
  background: var(--surface-muted);
  outline: none;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
.admin-search-bar__input:focus {
  border-color: var(--accent-600);
  background: var(--paper-elev);
  box-shadow: var(--shadow-focus);
}
/* Hide the browser's native search clear button — we render our own */
.admin-search-bar__input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.admin-search-bar__input::-ms-clear { display: none; }
.admin-search-bar__clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-400);
  display: flex;
  align-items: center;
  padding: 2px;
  border-radius: var(--r-sm);
}
.admin-search-bar__clear:hover { color: var(--ink-700); }

.admin-search-result-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: var(--text-sm);
  color: var(--ink-500);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--accent-50);
}
/* Activity log header — modern indigo/violet tint */
.admin-search-result-hint--activity {
  padding: 11px 18px;
  color: #4338ca;
  font-weight: 600;
  background: linear-gradient(90deg, #eef2ff 0%, #faf5ff 100%);
  border-bottom: 1px solid #e0e7ff;
}
.admin-search-result-hint--activity strong { color: #3730a3; }

/* ---- Admin user table additions ---- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}
.data-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-400);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--ink-800);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--surface-muted); }
.row--muted td { color: var(--ink-400); }
.td--actions { text-align: right; white-space: nowrap; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: var(--text-xs);
  font-weight: 500;
}
.badge--success { background: var(--success-100); color: var(--success-700); }
.badge--danger  { background: var(--danger-100);  color: var(--danger-700);  }
.badge--warn    { background: var(--accent-100);  color: var(--accent-700);  }
.badge--neutral { background: var(--ink-100);     color: var(--ink-500);     }

/* Buttons — ghost and danger-ghost variants used in table */
.btn--danger-ghost {
  color: var(--danger-700);
  background: transparent;
  border: 1px solid var(--danger-700);
}
.btn--danger-ghost:hover { background: var(--danger-100); }

/* bgedit__ additions for admin form */
.bgedit__hint {
  font-size: var(--text-xs);
  color: var(--ink-400);
  margin-top: 2px;
}
.bgedit__hint--inline { margin-left: 6px; }
.bgedit__row--check {
  flex-direction: row;
  align-items: flex-start;
  gap: 8px;
}
.bgedit__checkbox {
  width: 15px;
  height: 15px;
  margin-top: 2px;
  accent-color: var(--accent-600);
  cursor: pointer;
}
.bgedit__label--inline {
  font-weight: 400;
  cursor: pointer;
}

/* =========================================================
   Admin — User Management pages
   ========================================================= */

/* Page wrapper */
.admin-page {
  padding: 0;
}

/* Page header */
.admin-page__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: var(--paper-elev);
  border-bottom: 1px solid var(--border-subtle);
}
.admin-page__header-left { flex: 1; min-width: 0; }
.admin-page__eyebrow {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-400);
  margin-bottom: 4px;
}
.admin-page__title {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--ink-900);
  letter-spacing: -0.02em;
  margin: 0 0 3px;
  line-height: 1.15;
}
.activity-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
  width: 100%;
}
.activity-filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 220px;
}
.activity-filter--action {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

/* Multi-user dropdown picker (checkbox items inside the shared dropdown panel) */
.activity-filter--users { min-width: 260px; }
.activity-users__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  font-size: var(--text-sm);
  color: var(--ink-800);
  cursor: pointer;
  border-radius: 6px;
}
.activity-users__item:hover { background: var(--surface-muted); }
.activity-users__item input { flex: none; margin: 0; }
.activity-users__item--all {
  font-weight: 600;
  border-bottom: 1px solid var(--border-subtle);
  border-radius: 0;
  margin-bottom: 4px;
  padding-bottom: 8px;
}

/* Export / email actions (inside the table card, right-aligned) */
.activity-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-subtle);
}
.activity-actions__label {
  font-size: var(--text-sm);
  color: var(--ink-500);
  margin-right: auto;
}
.activity-actions__tz {
  display: inline-block;
  margin-left: 8px;
  font-size: var(--text-xs);
  color: var(--ink-400);
}
.activity-actions__tz strong { color: var(--ink-700); }
.activity-actions__form { margin: 0; display: inline-flex; }
.admin-page__sub {
  font-size: var(--text-sm);
  color: var(--ink-500);
  margin: 0;
}

/* Stats strip */
.admin-stats {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--paper-elev);
}
.admin-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 14px 20px;
  border-right: 1px solid var(--border-subtle);
  gap: 2px;
}
.admin-stat:last-child { border-right: none; }
.admin-stat__val {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--ink-900);
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.admin-stat__lbl {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-400);
}

/* Table card */
.admin-table-card {
  margin: 20px;
  background: var(--paper-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

/* Table */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}
.admin-table thead tr {
  background: var(--surface-muted);
}
.admin-table th {
  text-align: left;
  padding: 9px 16px;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-400);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.admin-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--ink-800);
  vertical-align: middle;
}
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover td { background: var(--surface-muted); }
.admin-table__row--muted td { opacity: 0.5; }
.admin-table__date {
  font-size: var(--text-sm);
  color: var(--ink-500);
  white-space: nowrap;
}
.admin-table__actions { text-align: right; white-space: nowrap; }
.admin-table__empty {
  text-align: center;
  padding: 48px 16px !important;
  color: var(--ink-400);
  font-size: var(--text-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* User cell — avatar + name + email */
.admin-user-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}
.admin-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: -0.01em;
}
.admin-avatar--admin {
  background: linear-gradient(135deg, #b45309, #78350f);
  color: #fff;
}
.admin-avatar--user {
  background: linear-gradient(135deg, var(--surface-nav), var(--surface-nav-hover));
  color: rgba(207,219,234,0.9);
}
.admin-user-cell__info { min-width: 0; }
.admin-user-cell__name {
  font-weight: 600;
  color: var(--ink-900);
  font-size: var(--text-base);
  white-space: nowrap;
}
.admin-user-cell__email {
  font-size: var(--text-sm);
  color: var(--ink-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Action group */
.admin-action-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.admin-you-tag {
  font-size: var(--text-xs);
  color: var(--ink-400);
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-weight: 500;
}

/* Permission toggle row */
.admin-perm-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  cursor: pointer;
  transition: border-color var(--dur-fast), background var(--dur-fast);
  background: var(--paper-elev);
}
.admin-perm-row:hover { border-color: var(--accent-600); background: var(--accent-50); }
.admin-perm-row__check {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--accent-600);
  cursor: pointer;
  flex-shrink: 0;
}
.admin-perm-row__body { flex: 1; min-width: 0; }
.admin-perm-row__title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--ink-900);
}
.admin-perm-row__desc {
  font-size: var(--text-sm);
  color: var(--ink-500);
  margin-top: 2px;
  line-height: 1.5;
}
.admin-perm-row__badge {
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  background: var(--accent-100);
  color: var(--accent-700);
  white-space: nowrap;
  flex-shrink: 0;
}
.admin-perm-row__badge--data-entry {
  background: var(--green-100, #dcfce7);
  color: var(--green-700, #15803d);
}

/* bgedit section additions for admin form */
.bgedit__section {
  background: var(--paper-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-xs);
}
.bgedit__section-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}
.bgedit__section-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  background: var(--surface-muted);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-600);
  flex-shrink: 0;
}
.bgedit__section-title {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--ink-900);
}
.bgedit__section-sub {
  font-size: var(--text-sm);
  color: var(--ink-500);
  margin-top: 1px;
}

/* ---- Status filter tabs ---- */
.admin-filter-tabs {
  display: flex;
  gap: 2px;
  padding: 0 0 12px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 0;
}
.admin-filter-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-500);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}
.admin-filter-tab:hover {
  background: var(--surface-muted);
  color: var(--ink-700);
}
.admin-filter-tab--active {
  background: var(--surface-muted);
  color: var(--ink-900);
  font-weight: 600;
}
.admin-filter-tab__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: var(--text-xs);
  font-weight: 500;
  background: var(--border);
  color: var(--ink-600);
}
.admin-filter-tab--active .admin-filter-tab__count {
  background: var(--accent-100);
  color: var(--accent-700);
}
.admin-filter-hint-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: capitalize;
}
.admin-filter-hint-badge--active {
  background: var(--green-100, #dcfce7);
  color: var(--green-700, #15803d);
}
.admin-filter-hint-badge--deactivated {
  background: var(--red-100, #fee2e2);
  color: var(--red-700, #b91c1c);
}

/* ── Activity — grouped by user (accordion) ─────────────── */
.activity-groups {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 0 8px;
}
.activity-group {
  border: 1px solid var(--border-subtle, #e5e7eb);
  border-radius: 12px;
  background: var(--surface, #fff);
  overflow: hidden;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.activity-group[open] {
  border-color: #c7d2fe;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.07);
}
.activity-group__summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.activity-group__summary::-webkit-details-marker { display: none; }
.activity-group__summary:hover { background: var(--surface-muted, #f8fafc); }
.activity-group__avatar {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #eef2ff;
  color: #4338ca;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
/* Per-user avatar colors (modern soft-tint palette) */
.activity-group__avatar--c0 { background: #eef2ff; color: #4f46e5; } /* indigo  */
.activity-group__avatar--c1 { background: #ecfdf5; color: #059669; } /* emerald */
.activity-group__avatar--c2 { background: #fff1f2; color: #e11d48; } /* rose    */
.activity-group__avatar--c3 { background: #fffbeb; color: #d97706; } /* amber   */
.activity-group__avatar--c4 { background: #eff6ff; color: #2563eb; } /* blue    */
.activity-group__avatar--c5 { background: #faf5ff; color: #9333ea; } /* violet  */
.activity-group__name {
  font-weight: 600;
  color: var(--ink-800, #1f2937);
  font-size: var(--text-sm, 14px);
}
.activity-group__count {
  flex: 0 0 auto;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-muted, #f1f5f9);
  color: var(--ink-500, #64748b);
  font-size: var(--text-xs, 12px);
  font-weight: 600;
}
.activity-group__latest {
  margin-left: auto;
  color: var(--ink-400, #94a3b8);
  font-size: var(--text-xs, 12px);
  font-variant-numeric: tabular-nums;
}
.activity-group__chevron {
  flex: 0 0 auto;
  color: var(--ink-400, #94a3b8);
  transition: transform 0.2s ease;
}
.activity-group[open] .activity-group__chevron { transform: rotate(180deg); }

.activity-timeline {
  list-style: none;
  margin: 0;
  padding: 4px 16px 12px 20px;
  border-top: 1px solid var(--border-subtle, #eef2f7);
}
.activity-event {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 9px 0 9px 16px;
  position: relative;
  border-left: 2px solid var(--border-subtle, #eef2f7);
}
.activity-event:last-child { padding-bottom: 2px; }
.activity-event__dot {
  position: absolute;
  left: -5px;
  top: 15px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
  box-shadow: 0 0 0 3px var(--surface, #fff);
}
.activity-event__dot--created    { background: #16a34a; }
.activity-event__dot--updated    { background: #2563eb; }
.activity-event__dot--deleted    { background: #dc2626; }
.activity-event__dot--closed     { background: #d97706; }
.activity-event__dot--merged     { background: #9333ea; }
.activity-event__dot--terminated { background: #e11d48; }
.activity-event__dot--signin     { background: #64748b; }
.activity-event__dot--default    { background: #94a3b8; }

/* Semantic event pills — color-coded by action type */
.activity-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}
.activity-pill::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}
.activity-pill--created    { background: #ecfdf5; color: #15803d; }
.activity-pill--updated    { background: #eff6ff; color: #1d4ed8; }
.activity-pill--deleted    { background: #fef2f2; color: #b91c1c; }
.activity-pill--closed     { background: #fffbeb; color: #b45309; }
.activity-pill--merged     { background: #faf5ff; color: #7e22ce; }
.activity-pill--terminated { background: #fff1f2; color: #be123c; }
.activity-pill--signin     { background: #f1f5f9; color: #475569; }
.activity-pill--default    { background: #f3f4f6; color: #6b7280; }

.activity-event__name { flex: 0 0 auto; }
.activity-event__desc {
  color: var(--ink-600, #475569);
  font-size: var(--text-sm, 14px);
}
.activity-event__changes {
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}
.activity-change {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--text-xs, 12px);
  background: var(--surface-muted, #f1f5f9);
  border: 1px solid var(--border-subtle, #eef2f7);
  border-radius: 6px;
  padding: 2px 8px;
}
.activity-change__field { font-weight: 600; color: var(--ink-700, #334155); }
.activity-change__field::after { content: ":"; }
.activity-change__old { color: var(--danger-700, #b91c1c); text-decoration: line-through; }
.activity-change__arrow { color: var(--ink-400, #94a3b8); }
.activity-change__new { color: var(--success-700, #15803d); font-weight: 500; }
.activity-event__link {
  color: #4338ca;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.activity-event__link:hover {
  color: #3730a3;
  border-bottom-color: currentColor;
}
.activity-event__time {
  margin-left: auto;
  color: var(--ink-400, #94a3b8);
  font-size: var(--text-xs, 12px);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.activity-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 48px 16px;
  color: var(--ink-400, #94a3b8);
  font-size: var(--text-sm, 14px);
}
.activity-empty svg { color: var(--ink-300, #cbd5e1); }

@media (max-width: 640px) {
  .activity-group__latest { display: none; }
  .activity-event { flex-wrap: wrap; }
  .activity-event__time { margin-left: 0; width: 100%; }
}

/* Profile page */
.profile-card {
  margin: 12px 12px 0;
  background: var(--paper-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.profile-card__identity {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-muted);
}
.profile-avatar {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-base);
  font-weight: 700;
}
.profile-card__name-block { flex: 1; min-width: 0; }
.profile-card__name {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--ink-900);
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.profile-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  margin: 0;
  padding: 0;
}
.profile-detail {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-subtle);
}
.profile-detail:nth-child(odd) { border-right: 1px solid var(--border-subtle); }
.profile-detail:last-child:nth-child(odd) { border-right: none; }
.profile-detail__label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-400);
  margin-bottom: 4px;
}
.profile-detail__value {
  font-size: var(--text-base);
  color: var(--ink-900);
  margin: 0;
  word-break: break-word;
}
.profile-stats {
  margin: 12px 12px 0;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.profile-page .admin-table-card { margin: 12px; }
.profile-page .admin-page__header { padding-left: 12px; padding-right: 12px; }
.profile-timeline { padding: 8px 20px 16px; }

/* Profile — inline edit (Turbo Frame) */
.profile-edit { margin: 12px 12px 0; }
.profile-edit .bgedit__section:last-of-type { margin-bottom: 0; }
.profile-edit__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}
.profile-inline-flash { margin: 12px 12px 0; }

/* Activity log header — count on the left, date filter on the right */
.profile-activity-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.profile-activity-head__count { min-width: 0; }
.profile-activity-head__filter {
  display: flex;
  align-items: center;
  gap: 8px;
}
.profile-activity-head__label {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #4338ca;
}
.profile-activity-head__date {
  padding: 5px 9px;
  border: 1px solid #c7d2fe;
  border-radius: var(--r-sm, 6px);
  font-size: var(--text-sm);
  color: var(--ink-900);
  background: #fff;
}

/* Read-only users may still manage their own account, so keep these visible. */
body.is-read-only .profile-action { display: inline-flex !important; }

/* Hide the header "Edit Profile" button while the inline edit form is open. */
.admin-page:has(#profile_card .profile-edit) .profile-edit-btn { display: none !important; }

@media (max-width: 640px) {
  .profile-details { grid-template-columns: minmax(0, 1fr); }
  .profile-detail:nth-child(odd) { border-right: none; }
}
