/* ===========================================================================
   Voice — User Menu (Dropdown) + Profile Page
   Depends on tokens.css being loaded first.
   =========================================================================== */

/* ─────────────────────────────────────────────────────────────
   User menu — trigger + popover
   ───────────────────────────────────────────────────────────── */
.user-menu { position: relative; display: inline-flex; align-items: center; }

.um-trigger {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px 4px 4px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-full);
  cursor: pointer;
  transition: background 120ms, border-color 120ms;
}
.um-trigger:hover { background: var(--bg-sunken); border-color: var(--border); }
.user-menu.open .um-trigger { background: var(--bg-sunken); border-color: var(--border); }

.um-trigger-avatar { position: relative; display: inline-flex; }
.um-online-dot {
  position: absolute;
  inset-inline-end: -1px; bottom: -1px;
  width: 8px; height: 8px;
  background: var(--success-500);
  border: 2px solid var(--bg-surface);
  border-radius: var(--r-full);
}
.um-online-dot.lg { width: 12px; height: 12px; inset-inline-end: 2px; bottom: 2px; border-width: 2.5px; }

.um-panel {
  position: absolute;
  top: calc(100% + 10px);
  inset-inline-end: 0;
  width: 340px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  z-index: 1000;
  overflow: hidden;
  animation: umIn 140ms ease-out;
}
@keyframes umIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.um-arrow {
  position: absolute;
  top: -6px; inset-inline-end: 18px;
  width: 12px; height: 12px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  border-inline-start: 1px solid var(--border);
  transform: rotate(45deg);
}

/* Header */
.um-header {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 16px 14px;
  background: linear-gradient(180deg, var(--brand-50) 0%, var(--bg-surface) 100%);
  border-bottom: 1px solid var(--border);
}
.um-avatar-wrap { position: relative; flex-shrink: 0; }
.um-header-info { min-width: 0; flex: 1; }
.um-name { font-weight: 700; font-size: 14px; color: var(--text); margin-bottom: 2px; }
.um-email {
  font-size: 12px; color: var(--text-muted);
  font-family: var(--font-en);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 8px;
}
.um-role-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  background: oklch(0.96 0.04 25);
  color: var(--danger-700);
  font-size: 11px; font-weight: 500;
  border-radius: var(--r-full);
}

/* Sections */
.um-section { padding: 10px 12px 4px; }
.um-section-label {
  font-size: 11px; color: var(--text-faint); font-weight: 500;
  padding: 0 4px 6px;
}

.um-workspace {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border: 1.5px solid var(--brand-300);
  background: oklch(0.99 0.012 70);
  border-radius: var(--r);
  position: relative;
}
.um-ws-logo {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--brand-700);
  color: white;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
  flex-shrink: 0;
  overflow: hidden;
}
.um-ws-logo img { width: 100%; height: 100%; object-fit: cover; }
.um-ws-info { flex: 1; min-width: 0; }
.um-ws-name { font-size: 13px; font-weight: 600; color: var(--text); }
.um-ws-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.um-ws-check { color: var(--brand-700); }

/* Nav */
.um-nav { padding: 4px; display: flex; flex-direction: column; }
.um-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: start;
  width: 100%;
  font-family: inherit;
}
.um-item:hover { background: var(--bg-sunken); }
.um-item > span:nth-child(2) { flex: 1; }
.um-item-static { cursor: default; }
.um-item-static:hover { background: transparent; }
.um-item-danger { color: var(--danger-700); }
.um-item-danger:hover { background: oklch(0.97 0.025 25); }
.um-logout-form { padding: 4px; margin: 0; }

.um-kbd {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--text-faint);
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-sunken);
}
.um-meta { font-size: 12px; color: var(--text-muted); }
.um-meta-icon { color: var(--text-faint); }
.um-badge {
  background: var(--danger-500); color: white;
  font-size: 11px; font-weight: 600;
  min-width: 20px; height: 20px;
  border-radius: var(--r-full);
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 6px;
}

.um-status-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  background: var(--success-50);
  color: var(--success-700);
  border-radius: var(--r-full);
  font-size: 11px; font-weight: 500;
}
.um-status-dot {
  width: 6px; height: 6px;
  background: var(--success-500);
  border-radius: var(--r-full);
}

/* Toggle (small switch used in menu + profile) */
.um-toggle {
  display: inline-block;
  width: 34px; height: 18px;
  background: var(--n-200);
  border-radius: var(--r-full);
  position: relative;
  cursor: pointer;
  transition: background 160ms;
  flex-shrink: 0;
}
.um-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  inset-inline-end: 2px;
  width: 14px; height: 14px;
  background: white;
  border-radius: var(--r-full);
  box-shadow: var(--shadow-sm);
  transition: inset-inline-end 160ms, inset-inline-start 160ms;
}
.um-toggle.is-on { background: var(--brand-600); }
.um-toggle.is-on::after { inset-inline-end: calc(100% - 16px); }

.um-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.um-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 16px 12px;
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--font-en);
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.um-build { font-family: var(--font-mono); }


/* ─────────────────────────────────────────────────────────────
   Profile page
   ───────────────────────────────────────────────────────────── */
.profile-page { display: flex; flex-direction: column; gap: 18px; padding-bottom: 32px; }

/* Hero */
.prof-hero {
  position: relative;
  background: linear-gradient(135deg, oklch(0.40 0.11 35) 0%, oklch(0.55 0.15 45) 70%, oklch(0.65 0.16 55) 100%);
  color: white;
  border-radius: var(--r-lg);
  padding: 22px 26px 0;
  overflow: hidden;
}
.prof-hero-bg {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(circle at 80% -20%, oklch(0.85 0.12 70 / 0.25), transparent 50%),
    radial-gradient(circle at 10% 110%, oklch(0.85 0.12 35 / 0.18), transparent 50%);
  pointer-events: none;
}

.prof-hero-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px;
  opacity: 0.85;
  position: relative;
  z-index: 1;
}
.prof-entity { display: inline-flex; align-items: center; gap: 5px; }
.prof-entity-sep { opacity: 0.5; }

.prof-hero-row {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-top: 14px;
  position: relative;
  z-index: 1;
  gap: 20px;
}

.prof-hero-badges { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.prof-name { font-size: 26px; font-weight: 700; margin: 0 0 8px; letter-spacing: -0.4px; }
.prof-sub { display: flex; align-items: center; gap: 8px; font-size: 13px; opacity: 0.9; }
.prof-sub > span { display: inline-flex; align-items: center; gap: 5px; }
.prof-sub-sep { opacity: 0.5; }

.prof-hero-avatar-wrap {
  position: relative;
  background: white;
  border-radius: 14px;
  padding: 6px;
  box-shadow: var(--shadow-lg);
}
.prof-hero-avatar-wrap .avatar { border-radius: 10px; font-size: 28px !important; }
.prof-avatar-edit {
  position: absolute;
  bottom: -2px; inset-inline-end: -2px;
  width: 22px; height: 22px;
  background: var(--brand-600);
  color: white;
  border-radius: var(--r-full);
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
  border: 2px solid white;
}

.prof-hero-actions {
  display: flex; gap: 8px;
  margin-top: 16px;
  position: relative;
  z-index: 1;
}
.prof-hero-actions .btn-primary {
  background: white;
  color: var(--brand-700);
  border: none;
}
.prof-hero-actions .btn-primary:hover { background: oklch(0.97 0.02 60); }
.prof-hero-actions .btn-secondary {
  background: rgba(255,255,255,0.15);
  color: white;
  border: 1px solid rgba(255,255,255,0.25);
}
.prof-hero-actions .btn-secondary:hover { background: rgba(255,255,255,0.22); }

.prof-hero-info {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  margin: 18px -26px 0;
  padding: 14px 26px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--text);
  position: relative;
  z-index: 1;
}
.prof-info-cell {
  display: flex; flex-direction: column; gap: 4px;
  padding: 0 16px;
  border-inline-start: 1px solid var(--border);
}
.prof-info-cell:first-child { border-inline-start: none; padding-inline-start: 0; }
.prof-info-cell:last-child { padding-inline-end: 0; }
.prof-info-label {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}
.prof-info-value {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Pills */
.prof-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 500;
}
.prof-pill-success { background: var(--success-50); color: var(--success-700); }
.prof-pill-warning { background: var(--warning-50); color: oklch(0.50 0.13 70); }
.prof-pill-danger  { background: oklch(0.96 0.04 25); color: var(--danger-700); }
.prof-pill-info    { background: var(--info-50);    color: oklch(0.40 0.12 230); }

.prof-dot {
  width: 6px; height: 6px;
  border-radius: var(--r-full);
}
.prof-dot-success { background: var(--success-500); }
.prof-dot-danger  { background: var(--danger-500); }

/* Tabs */
.prof-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  padding: 0 4px;
  margin-top: 4px;
}
.prof-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 120ms, border-color 120ms;
}
.prof-tab:hover { color: var(--text); }
.prof-tab.active { color: var(--brand-700); border-bottom-color: var(--brand-600); font-weight: 600; }

/* Layout grids */
.prof-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  align-items: start;
}
.prof-col-main, .prof-col-side { display: flex; flex-direction: column; gap: 16px; }

.prof-grid-narrow {
  max-width: 720px;
  display: flex; flex-direction: column; gap: 16px;
}

/* Card overrides for profile */
.prof-card { padding: 18px; }
.prof-card-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 8px;
}
.prof-card-head h3 { font-size: 15px; font-weight: 700; margin: 0; color: var(--text); }
.prof-card-head h4 { font-size: 13px; font-weight: 600; margin: 0; color: var(--text); }
.prof-card-month { font-size: 11px; color: var(--text-muted); padding: 3px 9px; background: var(--bg-sunken); border-radius: var(--r-full); }
.prof-card-desc { font-size: 12px; color: var(--text-muted); margin: 0 0 14px; line-height: 1.6; }
.prof-card-cta { margin-top: 12px; width: 100%; justify-content: center; }
.prof-card-cta-row { margin-top: 14px; display: flex; }
.prof-link { font-size: 12px; color: var(--brand-700); font-weight: 500; }

/* Stats grid */
.prof-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.prof-stat {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.prof-stat-icon {
  width: 24px; height: 24px;
  background: var(--info-50);
  color: oklch(0.50 0.12 230);
  border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
}
.prof-stat-icon-success { background: var(--success-50); color: var(--success-700); }
.prof-stat-icon-warning { background: var(--warning-50); color: oklch(0.50 0.13 70); }
.prof-stat-icon-info    { background: oklch(0.96 0.025 25); color: var(--brand-700); }
.prof-stat-label { font-size: 11px; color: var(--text-muted); }
.prof-stat-value { font-size: 22px; font-weight: 700; color: var(--text); font-family: var(--font-mono); letter-spacing: -0.5px; }

/* Daily chart */
.prof-chart { margin-top: 8px; }
.prof-chart-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.prof-chart-meta { font-size: 11px; color: var(--text-muted); }
.prof-chart-bars {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 4px;
  height: 64px;
  padding: 0 2px;
}
.prof-bar {
  flex: 1;
  display: flex; flex-direction: column; align-items: center;
  gap: 4px;
  height: 100%;
}
.prof-bar-fill {
  width: 100%;
  background: linear-gradient(180deg, var(--brand-300), var(--brand-600));
  border-radius: 3px 3px 0 0;
  min-height: 4px;
  transition: opacity 120ms;
}
.prof-bar:hover .prof-bar-fill { opacity: 0.85; }
.prof-bar-label {
  font-size: 10px; color: var(--text-faint);
  font-family: var(--font-mono);
}

/* Permissions */
.prof-perm-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.prof-perm {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px;
}
.prof-empty-row { font-size: 12px; color: var(--text-faint); padding: 8px 0; }

/* Meta list (key/value) */
.prof-meta-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }
.prof-meta-list > li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.prof-meta-list > li:last-child { border-bottom: none; }
.prof-meta-key { display: inline-flex; align-items: center; gap: 8px; color: var(--text-muted); }
.prof-meta-val { font-weight: 500; font-size: 12px; }
.prof-meta-val.is-success { color: var(--success-700); }
.prof-meta-val.is-warning { color: oklch(0.50 0.13 70); }
.prof-meta-val.is-info    { color: oklch(0.50 0.12 230); }

/* Timeline */
.prof-timeline { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }
.prof-timeline-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.prof-timeline-item:last-child { border-bottom: none; }
.prof-timeline-icon {
  width: 32px; height: 32px;
  border-radius: var(--r-full);
  border: 1.5px solid var(--border);
  background: var(--bg-surface);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--brand-700);
  flex-shrink: 0;
}
.prof-timeline-icon-success { color: var(--success-700); border-color: oklch(0.85 0.08 150); }
.prof-timeline-icon-warning { color: oklch(0.50 0.13 70); border-color: oklch(0.85 0.10 80); }
.prof-timeline-icon-danger  { color: var(--danger-700); border-color: oklch(0.85 0.10 25); }
.prof-timeline-body { flex: 1; min-width: 0; }
.prof-timeline-title { font-size: 13px; font-weight: 500; color: var(--text); }
.prof-timeline-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.prof-timeline-time { font-size: 11px; color: var(--text-faint); white-space: nowrap; }

/* Forms */
.prof-form { display: flex; flex-direction: column; gap: 14px; }
.prof-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.prof-form-actions { display: flex; gap: 8px; align-items: center; }

.prof-locked-tag {
  display: inline-flex; align-items: center; gap: 4px;
  margin-inline-start: 6px;
  padding: 2px 7px;
  background: oklch(0.96 0.04 25);
  color: var(--danger-700);
  font-size: 10px; font-weight: 500;
  border-radius: var(--r-full);
  vertical-align: middle;
}

.prof-field-help {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 6px 2px 0;
}

/* تلميح صغير بجانب عنوان الحقل — يظهر النص عند المرور بالماوس (title) لتوفير المساحة */
.label-hint {
  display: inline-flex;
  align-items: center;
  margin-inline-start: 5px;
  color: var(--text-muted);
  cursor: help;
  vertical-align: middle;
  transition: color .15s;
}
.label-hint:hover { color: var(--primary-600, var(--text)); }

.prof-form .input:disabled,
.prof-form .input[readonly] {
  background: var(--bg-sunken);
  color: var(--text-muted);
  cursor: not-allowed;
}

.prof-error {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: oklch(0.97 0.025 25);
  border: 1px solid oklch(0.88 0.06 25);
  color: var(--danger-700);
  border-radius: var(--r);
  font-size: 13px;
}

.prof-flash {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  background: var(--success-50);
  border: 1px solid oklch(0.85 0.07 150);
  color: var(--success-700);
  border-radius: var(--r);
  font-size: 13px;
}

.prof-empty {
  padding: 28px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  border: 1px dashed var(--border);
  border-radius: var(--r);
}

/* Email change */
.prof-email-current {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin-bottom: 16px;
}
.prof-email-icon {
  width: 36px; height: 36px;
  background: var(--brand-50);
  color: var(--brand-700);
  border-radius: var(--r);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.prof-email-label { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.prof-email-value { font-size: 14px; color: var(--text); font-family: var(--font-en); font-weight: 500; }

.prof-email-pending {
  padding: 14px;
  background: oklch(0.98 0.025 80);
  border: 1px solid oklch(0.85 0.10 80);
  border-radius: var(--r);
}
.prof-email-pending-head {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: oklch(0.45 0.13 70);
  margin-bottom: 4px;
}

/* 2FA section */
.prof-2fa-status {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}

.prof-2fa-method-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border: 1.5px solid var(--brand-300);
  background: oklch(0.99 0.012 70);
  border-radius: var(--r);
  margin-bottom: 14px;
}
.prof-2fa-method-icon {
  width: 38px; height: 38px;
  background: var(--brand-50);
  color: var(--brand-700);
  border-radius: var(--r);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.prof-2fa-method-body { flex: 1; min-width: 0; }
.prof-2fa-method-title { font-size: 13px; font-weight: 600; color: var(--text); }
.prof-2fa-method-desc { font-size: 11px; color: var(--text-muted); margin-top: 2px; line-height: 1.5; }

.prof-2fa-setup {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 22px;
  align-items: start;
  margin-top: 6px;
}
.prof-2fa-qr {
  background: white;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  display: inline-flex; justify-content: center; align-items: center;
}
.prof-2fa-qr svg { width: 100%; height: auto; max-width: 220px; display: block; }
.prof-2fa-setup-body { display: flex; flex-direction: column; gap: 14px; }

.prof-2fa-manual {
  background: var(--bg-sunken);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r);
  padding: 10px 12px;
}
.prof-2fa-manual-label {
  display: block;
  font-size: 11px; color: var(--text-muted);
  margin-bottom: 4px;
}
.prof-2fa-secret {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  word-break: break-all;
  letter-spacing: 0.5px;
}

.prof-2fa-code {
  font-family: var(--font-mono) !important;
  font-size: 18px !important;
  letter-spacing: 4px !important;
  text-align: center !important;
}

.prof-2fa-cancel-form { margin: 0; }
.prof-link-danger {
  background: none; border: none;
  color: var(--danger-700);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  padding: 4px 0;
}
.prof-link-danger:hover { text-decoration: underline; }

.prof-2fa-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
}

.prof-2fa-disable-form {
  margin-top: 14px;
  padding: 14px;
  background: oklch(0.98 0.018 25);
  border: 1px solid oklch(0.88 0.06 25);
  border-radius: var(--r);
}

/* Recovery codes display */
.prof-recovery-card { border: 1.5px solid var(--warning-500); background: oklch(0.99 0.015 80); }
.prof-recovery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin: 14px 0;
  padding: 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
}
.prof-recovery-code {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  background: var(--bg-sunken);
  padding: 6px 10px;
  border-radius: 6px;
  letter-spacing: 0.5px;
  text-align: center;
}
.prof-recovery-actions { display: flex; gap: 8px; }

/* Sessions */
.prof-sessions { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }
.prof-session {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.prof-session:last-child { border-bottom: none; }
.prof-session-icon {
  width: 40px; height: 40px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--r);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
}
.prof-session-body { flex: 1; min-width: 0; }
.prof-session-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--text);
  margin-bottom: 4px;
}
.prof-session-meta {
  display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap;
  font-size: 11px; color: var(--text-muted);
}
.prof-mono { font-family: var(--font-mono); }
.prof-session-revoke { color: var(--danger-700); }
.prof-session-revoke:hover { background: oklch(0.97 0.025 25); }

/* ─────────────────────────────────────────────────────────────
   OTP Modal (popup for sensitive confirmations)
   ───────────────────────────────────────────────────────────── */
.otp-modal-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: oklch(0.2 0.012 70 / 0.5);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: modalFadeIn 160ms ease-out;
}
@keyframes modalFadeIn { from { opacity: 0; } to { opacity: 1; } }

.otp-modal {
  background: var(--bg-surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  width: 100%;
  max-width: 520px;
  overflow: hidden;
  animation: modalIn 200ms cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.otp-modal-head {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 20px 24px 18px;
  position: relative;
}
.otp-modal-icon {
  width: 44px; height: 44px;
  background: var(--brand-50);
  color: var(--brand-700);
  border-radius: var(--r-md);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.otp-modal-titles { flex: 1; min-width: 0; }
.otp-modal-title {
  font-size: 17px; font-weight: 700; margin: 0 0 4px;
  color: var(--text);
}
.otp-modal-subtitle {
  font-size: 12px; color: var(--text-muted); margin: 0;
  line-height: 1.6;
}
.otp-modal-close-form { margin: 0; }
.otp-modal-close {
  background: transparent; border: none; cursor: pointer;
  width: 32px; height: 32px;
  border-radius: var(--r-full);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: background 120ms, color 120ms;
}
.otp-modal-close:hover { background: var(--bg-sunken); color: var(--text); }

.otp-modal-divider { height: 1px; background: var(--border); margin: 0; }

.otp-modal-body { padding: 22px 24px 18px; }
.otp-modal-text {
  font-size: 13px; color: var(--text-muted); line-height: 1.7;
  text-align: center; margin: 0 0 18px;
}
.otp-modal-text strong { color: var(--text); font-family: var(--font-en); }

.otp-modal-error {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; margin-bottom: 14px;
  background: #fef2f2; border: 1px solid #fecaca;
  color: #b91c1c; border-radius: var(--r);
  font-size: 12.5px;
}

.otp-modal-boxes {
  display: flex; gap: 10px; direction: ltr;
  justify-content: center; margin: 6px 0 16px;
}
.otp-modal-box {
  width: 52px; height: 60px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 24px; font-weight: 600;
  color: var(--text);
  background: var(--bg-surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--r-md);
  transition: border-color 120ms, box-shadow 120ms;
  outline: none; padding: 0;
}
.otp-modal-box:focus {
  border-color: var(--brand-600);
  box-shadow: 0 0 0 4px oklch(0.65 0.16 48 / 0.15);
}
.otp-modal-box[value]:not([value=""]),
.otp-modal-box:not(:placeholder-shown) { border-color: var(--brand-400); }

.otp-modal-meta {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap;
  font-size: 12px; color: var(--text-muted);
}
.otp-modal-meta-cell { display: inline-flex; align-items: center; gap: 6px; }
.otp-modal-meta strong { font-family: var(--font-mono); color: var(--brand-700); font-weight: 600; }

.otp-modal-resend-btn {
  display: inline-flex; align-items: center; gap: 5px;
  background: none; border: none; cursor: pointer;
  font-family: inherit; font-size: 12px;
  color: var(--brand-700); font-weight: 500;
  padding: 4px 6px; border-radius: 6px;
}
.otp-modal-resend-btn:hover { background: oklch(0.96 0.04 48); }

.otp-modal-foot {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap-reverse;
  padding: 14px 24px;
  background: var(--bg-sunken);
  border-top: 1px solid var(--border);
}
.otp-modal-foot-info {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-muted);
}
.otp-modal-foot-actions { display: flex; gap: 8px; }

@media (max-width: 540px) {
  .otp-modal-box { width: 42px; height: 52px; font-size: 20px; }
  .otp-modal-boxes { gap: 6px; }
}

/* ─────────────────────────────────────────────────────────────
   OTP Challenge page
   ───────────────────────────────────────────────────────────── */
.otp-back-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-muted);
  background: none; border: none; cursor: pointer;
  padding: 0; font-family: inherit;
}
.otp-back-link:hover { color: var(--text); }

.otp-title { font-size: 28px; font-weight: 700; margin: 14px 0 8px; letter-spacing: -0.3px; }
.otp-sub {
  font-size: 14px; color: var(--text-muted);
  line-height: 1.7; margin: 0 0 6px;
}
.otp-account {
  font-size: 13px; color: var(--text);
  margin: 0 0 22px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.otp-account strong { font-family: var(--font-en); font-weight: 600; }
.otp-change-link { color: var(--brand-700); font-size: 12px; font-weight: 500; }
.otp-change-link:hover { text-decoration: underline; }

.otp-flash {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 13px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 14px;
}
.otp-flash-success { background: var(--success-50); border: 1px solid oklch(0.85 0.07 150); color: var(--success-700); }
.otp-flash-error   { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }

.otp-form { display: flex; flex-direction: column; gap: 14px; }

.otp-boxes {
  display: flex;
  gap: 8px;
  direction: ltr;
  justify-content: center;
  margin: 4px 0 4px;
}
.otp-box {
  width: 48px; height: 56px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 22px; font-weight: 600;
  color: var(--text);
  background: var(--bg-surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--r);
  transition: border-color 120ms, box-shadow 120ms;
  outline: none;
  padding: 0;
}
.otp-box:focus {
  border-color: var(--brand-600);
  box-shadow: 0 0 0 4px oklch(0.65 0.16 48 / 0.12);
}
.otp-box:not(:placeholder-shown), .otp-box[value]:not([value=""]) {
  border-color: var(--brand-400);
}

.otp-timer-row {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 12px; color: var(--text-muted);
  margin-top: 2px;
}
.otp-timer-row strong {
  font-family: var(--font-mono);
  color: var(--brand-700);
  font-weight: 600;
}

.otp-trust-row {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 10px 12px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
  line-height: 1.6;
}
.otp-trust-row input[type="checkbox"] {
  accent-color: var(--brand-600);
  width: 16px; height: 16px;
  flex-shrink: 0;
  margin-top: 2px;
}

.otp-info-card {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 14px;
}
.otp-info-text { line-height: 1.6; }
.otp-resend-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: none; cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px; font-family: inherit;
  color: var(--brand-700); font-weight: 500;
}
.otp-resend-btn:hover:not(:disabled) { background: oklch(0.96 0.04 48); }
.otp-resend-btn:disabled { color: var(--text-faint); cursor: not-allowed; }
.otp-resend-btn strong { font-family: var(--font-mono); font-weight: 600; }

.otp-switch-section { margin-top: 22px; }
.otp-switch-divider {
  display: flex; align-items: center; gap: 12px;
  color: var(--text-faint); font-size: 12px;
  margin-bottom: 14px;
}
.otp-switch-divider::before,
.otp-switch-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

.otp-switch-form { margin: 0 0 8px; }
.otp-switch-card {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  cursor: pointer;
  font-family: inherit;
  text-align: start;
  transition: border-color 120ms, background 120ms;
}
.otp-switch-card:hover {
  border-color: var(--brand-300);
  background: oklch(0.99 0.012 70);
}
.otp-switch-icon {
  width: 38px; height: 38px;
  background: var(--info-50);
  color: oklch(0.40 0.12 230);
  border-radius: var(--r);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.otp-switch-body { flex: 1; min-width: 0; }
.otp-switch-title { font-size: 13px; font-weight: 600; color: var(--text); }
.otp-switch-desc { font-size: 11px; color: var(--text-muted); margin-top: 2px; line-height: 1.5; }

.otp-notice {
  display: flex; gap: 8px;
  padding: 12px 14px;
  background: var(--info-50);
  border: 1px solid oklch(0.85 0.07 230);
  color: oklch(0.32 0.10 230);
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.7;
  margin-top: 16px;
}

/* ─────────────────────────────────────────────────────────────
   Roles & Permissions page
   ───────────────────────────────────────────────────────────── */
.role-flash {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; margin-bottom: 14px;
  background: var(--success-50);
  border: 1px solid oklch(0.85 0.07 150);
  color: var(--success-700);
  border-radius: var(--r);
  font-size: 13px;
}

.roles-toolbar {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 14px;
  display: flex; gap: 10px; align-items: center;
}

.roles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.role-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  display: flex; flex-direction: column; gap: 14px;
  transition: border-color 120ms, box-shadow 120ms;
}
.role-card:hover {
  border-color: var(--brand-300);
  box-shadow: var(--shadow-sm);
}
.role-card.is-protected {
  background: linear-gradient(180deg, oklch(0.99 0.012 60) 0%, var(--bg-surface) 100%);
  border-color: oklch(0.88 0.06 25);
}

.role-card-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 10px;
}
.role-card-title { display: flex; align-items: center; gap: 12px; }
.role-card-icon {
  width: 38px; height: 38px;
  border-radius: var(--r);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.role-tone-brand   { background: var(--brand-50);   color: var(--brand-700); }
.role-tone-info    { background: var(--info-50);    color: oklch(0.40 0.12 230); }
.role-tone-success { background: var(--success-50); color: var(--success-700); }
.role-tone-warning { background: var(--warning-50); color: oklch(0.50 0.13 70); }
.role-tone-neutral { background: var(--n-100);      color: var(--n-700); }

.role-card-name {
  font-size: 15px; font-weight: 700; color: var(--text);
  margin-bottom: 2px;
}
.role-card-slug {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--text-faint);
}

.role-card-stats {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 10px;
  background: var(--bg-sunken);
  border-radius: var(--r);
}
.role-card-stat {
  display: flex; align-items: center; gap: 10px;
}
.role-card-stat-icon {
  width: 28px; height: 28px;
  border-radius: var(--r);
  background: var(--bg-surface);
  color: var(--brand-700);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.role-card-stat-val {
  font-size: 16px; font-weight: 700; color: var(--text);
  font-family: var(--font-mono); line-height: 1.2;
}
.role-card-stat-lbl { font-size: 11px; color: var(--text-muted); }

.role-card-perms {
  display: flex; flex-direction: column; gap: 6px;
}
.role-card-pgroup {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px;
}
.role-card-pgroup-label {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text);
}
.role-card-pgroup-count {
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-size: 11px;
  padding: 1px 7px;
  background: var(--bg-sunken);
  border-radius: var(--r-full);
}
.role-card-empty {
  font-size: 12px; color: var(--text-faint);
  text-align: center; padding: 12px;
  background: var(--bg-sunken);
  border-radius: var(--r);
  margin: 0;
}

.role-card-foot {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.role-link {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--brand-700); font-weight: 500;
}
.role-link:hover { text-decoration: underline; }
.role-card-actions { display: flex; gap: 4px; }
.role-btn-danger:hover { color: var(--danger-700); background: oklch(0.97 0.025 25); }
.role-card-action-disabled {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  color: var(--text-faint); cursor: not-allowed;
}

.role-empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 56px 20px;
  background: var(--bg-surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
  color: var(--text-muted);
}
.role-empty-state h3 { margin: 14px 0 6px; color: var(--text); font-size: 15px; }
.role-empty-state p { margin: 0 0 16px; font-size: 13px; }

/* ── Role create/edit modal ── */
.role-modal-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: oklch(0.2 0.012 70 / 0.5);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: modalFadeIn 160ms ease-out;
}
.role-modal {
  background: var(--bg-surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  width: 100%;
  max-width: 760px;
  max-height: 92vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: modalIn 200ms cubic-bezier(0.2, 0.9, 0.3, 1);
}
.role-modal-head {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.role-modal-icon {
  width: 44px; height: 44px;
  background: var(--brand-50);
  color: var(--brand-700);
  border-radius: var(--r-md);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.role-modal-titles { flex: 1; min-width: 0; }
.role-modal-titles h2 { font-size: 17px; font-weight: 700; margin: 0 0 4px; color: var(--text); }
.role-modal-code {
  display: inline-block;
  margin-inline-start: 6px;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--bg-sunken, var(--n-100));
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  vertical-align: middle;
}
.role-modal-titles p  { font-size: 12px; color: var(--text-muted); margin: 0; line-height: 1.6; }
.role-modal-close {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--r-full);
  color: var(--text-muted);
  transition: background 120ms, color 120ms;
}
.role-modal-close:hover { background: var(--bg-sunken); color: var(--text); }

.role-modal-body {
  flex: 1; overflow-y: auto;
  padding: 18px 24px;
  display: flex; flex-direction: column; gap: 14px;
}
.role-modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 24px;
  background: var(--bg-sunken);
  border-top: 1px solid var(--border);
}

.role-modal-perms-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.role-modal-perms-head h3 { font-size: 13px; font-weight: 600; margin: 0; color: var(--text); }
.role-modal-perms-toolbar { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.role-modal-perms-toolbar .prof-link,
.role-modal-perms-toolbar .prof-link-danger {
  background: none; border: none; cursor: pointer; padding: 0;
  font-family: inherit; font-weight: 500;
}

.role-modal-perms {
  display: flex; flex-direction: column; gap: 12px;
}

.role-pgroup {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--bg-surface);
}
.role-pgroup-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--border);
}
.role-pgroup-label {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
  flex: 1; min-width: 0;
}
.role-pgroup-toggle {
  accent-color: var(--brand-600);
  width: 16px; height: 16px;
  flex-shrink: 0;
}
.role-pgroup-icon {
  width: 28px; height: 28px;
  background: var(--brand-50);
  color: var(--brand-700);
  border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.role-pgroup-title { font-size: 13px; font-weight: 600; color: var(--text); }
.role-pgroup-desc  { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.role-pgroup-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  padding: 2px 8px;
  background: var(--bg-surface);
  border-radius: var(--r-full);
}

.role-pgroup-items {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0;
}
.role-perm-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px;
  border-top: 1px solid var(--border);
  cursor: pointer;
  font-size: 12.5px;
  transition: background 120ms;
}
.role-perm-item:hover { background: var(--bg-sunken); }
.role-perm-item:nth-child(-n+2) { border-top: none; }
.role-perm-item:nth-child(2n) { border-inline-start: 1px solid var(--border); }
.role-perm-item input[type="checkbox"] {
  accent-color: var(--brand-600);
  width: 15px; height: 15px;
  flex-shrink: 0;
}
.role-perm-name { flex: 1; color: var(--text); }
.role-perm-slug {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  background: var(--bg-sunken);
  padding: 1px 6px;
  border-radius: 4px;
}
.role-perm-item input:checked + .role-perm-name { color: var(--brand-700); font-weight: 500; }

@media (max-width: 720px) {
  .role-pgroup-items { grid-template-columns: 1fr; }
  .role-perm-item:nth-child(-n+2) { border-top: 1px solid var(--border); }
  .role-perm-item:nth-child(1)    { border-top: none; }
  .role-perm-item:nth-child(2n)   { border-inline-start: none; }
}

/* ─────────────────────────────────────────────────────────────
   Invoice details modal (AJAX-loaded)
   ───────────────────────────────────────────────────────────── */
dialog.inv-details-dialog {
  padding: 0;
  border: none;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  background: var(--bg-app);
  max-width: 1100px;
  width: 92vw;
  max-height: 90vh;
  overflow: hidden;
}
dialog.inv-details-dialog::backdrop {
  background: oklch(0.2 0.012 70 / 0.5);
  backdrop-filter: blur(3px);
}

.inv-details-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.inv-details-title {
  font-size: 15px; font-weight: 600;
  margin: 0; color: var(--text);
}
.inv-details-close {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none; cursor: pointer;
  border-radius: var(--r-full);
  color: var(--text-muted);
  transition: background 120ms, color 120ms;
}
.inv-details-close:hover { background: var(--bg-sunken); color: var(--text); }

.inv-details-body {
  padding: 18px 22px 22px;
  overflow-y: auto;
  max-height: calc(90vh - 56px);
}
.inv-details-loading {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 80px 20px;
  color: var(--text-muted);
  font-size: 13px;
}
.inv-details-error {
  padding: 60px 20px;
  text-align: center;
  color: var(--danger-700);
  font-size: 13px;
}

/* The dense line-items table scrolls horizontally rather than crushing
   its many columns inside the narrow modal. */
.inv-items-scroll { overflow-x: auto; }
.inv-items-scroll > table { min-width: 640px; }

/* Responsive */
@media (max-width: 900px) {
  .prof-grid { grid-template-columns: 1fr; }
  .prof-stats { grid-template-columns: repeat(2, 1fr); }
  .prof-hero-info { grid-template-columns: repeat(2, 1fr); gap: 12px 0; }
  .prof-info-cell { border-inline-start: none; padding-inline: 0; }
  .prof-form-row { grid-template-columns: 1fr; }
  .um-panel { width: 300px; }
}

/* Invoice details modal — stack the main body and the info sidebar
   into a single column so neither gets crushed on phones/tablets. */
@media (max-width: 760px) {
  dialog.inv-details-dialog { width: 96vw; }
  .inv-details-grid { grid-template-columns: 1fr !important; }
  .inv-details-body { padding: 14px 14px 18px; }
  .inv-details-head { padding: 12px 14px; }
}
