/* =============================================================================
   PIM Activation Portal — portal.css
   Copyright © 2026 Sebastian Flæng Markdanner — MIT License
   Three themes: dark (default), light, high-contrast
   ============================================================================= */

/* Ensure [hidden] always wins over display rules set on specific elements.
   Without this, ID-selector rules (e.g. #loading-overlay { display:flex })
   override the browser's [hidden] { display:none } from the UA stylesheet
   because ID selectors have higher specificity than attribute selectors. */
[hidden] { display: none !important; }

/* ── Dark theme (base / default) ─────────────────────────────────────────── */
:root {
  /* MTA Brand Palette */
  --brand-50:      #eff6ff;
  --brand-100:     #dbeafe;
  --brand-200:     #bfdbfe;
  --brand-500:     #3b82f6;
  --brand-600:     #2563eb;
  --brand-700:     #1d4ed8;
  --brand-800:     #1e40af;

  /* Theme variables */
  --bg:            #0f172a;
  --bg-surface:    #1e293b;
  --bg-raised:     #263548;
  --bg-hover:      rgba(255,255,255,0.04);
  --bg-selected:   rgba(59,130,246,0.10);
  --text:          #f1f5f9;
  --text-muted:    #94a3b8;
  --text-faint:    #475569;
  --border:        rgba(148,163,184,0.15);
  --border-strong: rgba(148,163,184,0.30);
  --primary:       var(--brand-600);
  --primary-hover: var(--brand-700);
  --primary-active: var(--brand-800);
  --primary-dim:   rgba(37,99,235,0.18);
  --danger:        #ef4444;
  --danger-dim:    rgba(239,68,68,0.18);
  --success:       #10b981;
  --success-dim:   rgba(16,185,129,0.18);
  --warning:       #f59e0b;
  --warning-dim:   rgba(245,158,11,0.18);
  --purple:        #a78bfa;
  --purple-dim:    rgba(167,139,250,0.18);
  
  --badge-entra-bg:  #1e3a5f;
  --badge-entra-fg:  #93c5fd;
  --badge-group-bg:  #2d1b69;
  --badge-group-fg:  #c4b5fd;
  --badge-azure-bg:  #134e4a;
  --badge-azure-fg:  #5eead4;

  --header-bg:     rgba(15,23,42,0.97);
  --shadow:        0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.15);
  --shadow-sm:     0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-md:     0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  
  --radius:        12px; /* MTA .card radius */
  --radius-sm:     8px;  /* MTA button radius */
  --radius-xs:     4px;
  
  --focus-ring:    0 0 0 2px var(--brand-500);
  --modal-overlay: rgba(2, 6, 23, 0.6);
  --input-bg:      rgba(255,255,255,0.06);
  --input-border:  rgba(148,163,184,0.22);
  --scroll-thumb:  rgba(148,163,184,0.30);
  --footer-height: 56px;
  color-scheme: dark;
}

/* ── Light theme ─────────────────────────────────────────────────────────── */
:root[data-theme="light"] {
  --bg:            #ffffff;
  --bg-surface:    #ffffff;
  --bg-raised:     #f8fafc;
  --bg-hover:      rgba(0,0,0,0.03);
  --bg-selected:   rgba(37,99,235,0.07);
  --text:          #0f172a;
  --text-muted:    #475569;
  --text-faint:    #94a3b8;
  --border:        #e2e8f0;
  --border-strong: #cbd5e1;
  --primary:       var(--brand-600);
  --primary-hover: var(--brand-700);
  --primary-active: var(--brand-800);
  --primary-dim:   rgba(37,99,235,0.12);
  --danger:        #dc2626;
  --danger-dim:    rgba(220,38,38,0.12);
  --success:       #059669;
  --success-dim:   rgba(5,150,105,0.12);
  --warning:       #d97706;
  --warning-dim:   rgba(217,119,6,0.12);
  --purple:        #7c3aed;
  --purple-dim:    rgba(124,58,237,0.12);
  --badge-entra-bg:  #dbeafe;
  --badge-entra-fg:  #1d4ed8;
  --badge-group-bg:  #ede9fe;
  --badge-group-fg:  #6d28d9;
  --badge-azure-bg:  #ccfbf1;
  --badge-azure-fg:  #0f766e;
  --header-bg:     rgba(255,255,255,0.97);
  --shadow:        0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-sm:     0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --modal-overlay: rgba(15, 23, 42, 0.6);
  --input-bg:      #ffffff;
  --input-border:  #e2e8f0;
  --scroll-thumb:  rgba(15,23,42,0.20);
  --focus-ring:    0 0 0 2px var(--brand-500);
  color-scheme: light;
}

/* ── High Contrast theme ─────────────────────────────────────────────────── */
:root[data-theme="hc"] {
  --bg:            #000000;
  --bg-surface:    #0a0a0a;
  --bg-raised:     #111111;
  --bg-hover:      rgba(255,255,0,0.07);
  --bg-selected:   rgba(255,255,0,0.12);
  --text:          #ffffff;
  --text-muted:    #dddddd;
  --text-faint:    #aaaaaa;
  --border:        #ffffff;
  --border-strong: #ffffff;
  --primary:       #ffff00;
  --primary-dim:   rgba(255,255,0,0.15);
  --danger:        #ff4444;
  --danger-dim:    rgba(255,68,68,0.15);
  --success:       #00ff88;
  --success-dim:   rgba(0,255,136,0.15);
  --warning:       #ffaa00;
  --warning-dim:   rgba(255,170,0,0.15);
  --purple:        #ff80ff;
  --purple-dim:    rgba(255,128,255,0.15);
  --badge-entra-bg:  #003080;
  --badge-entra-fg:  #ffffff;
  --badge-group-bg:  #500050;
  --badge-group-fg:  #ffffff;
  --badge-azure-bg:  #005040;
  --badge-azure-fg:  #ffffff;
  --header-bg:     #000000;
  --shadow:        none;
  --shadow-sm:     none;
  --radius:        4px;
  --radius-sm:     2px;
  --radius-xs:     1px;
  --modal-overlay: rgba(0,0,0,0.90);
  --input-bg:      #000000;
  --input-border:  #ffffff;
  --scroll-thumb:  #ffffff;
  --focus-ring:    0 0 0 2px #ffff00;
  color-scheme: dark;
}

/* ── System auto-detect (light preference, no explicit theme) ─────────────── */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg:            #f1f5f9;
    --bg-surface:    #ffffff;
    --bg-raised:     #f8fafc;
    --bg-hover:      rgba(0,0,0,0.03);
    --bg-selected:   rgba(37,99,235,0.07);
    --text:          #0f172a;
    --text-muted:    #475569;
    --text-faint:    #94a3b8;
    --border:        rgba(15,23,42,0.10);
    --border-strong: rgba(15,23,42,0.22);
    --primary:       #2563eb;
    --primary-dim:   rgba(37,99,235,0.12);
    --danger:        #dc2626;
    --danger-dim:    rgba(220,38,38,0.12);
    --success:       #059669;
    --success-dim:   rgba(5,150,105,0.12);
    --warning:       #d97706;
    --warning-dim:   rgba(217,119,6,0.12);
    --purple:        #7c3aed;
    --purple-dim:    rgba(124,58,237,0.12);
    --badge-entra-bg:  #dbeafe;
    --badge-entra-fg:  #1d4ed8;
    --badge-group-bg:  #ede9fe;
    --badge-group-fg:  #6d28d9;
    --badge-azure-bg:  #ccfbf1;
    --badge-azure-fg:  #0f766e;
    --header-bg:     rgba(255,255,255,0.97);
    --shadow:        0 4px 24px rgba(0,0,0,0.08);
    --shadow-sm:     0 2px 8px  rgba(0,0,0,0.05);
    --modal-overlay: rgba(0,0,0,0.40);
    --input-bg:      #ffffff;
    --input-border:  rgba(15,23,42,0.16);
    --scroll-thumb:  rgba(15,23,42,0.20);
    --focus-ring:    0 0 0 2px rgba(37,99,235,0.45);
    color-scheme: light;
  }
}

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background:  var(--bg);
  color:       var(--text);
  min-height:  100dvh;
}
a { color: var(--primary); text-decoration: none; }
@media (hover: hover) and (pointer: fine) {

  a:hover { text-decoration: underline; }

}
:focus-visible { outline: none; box-shadow: var(--focus-ring); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 3px; }

/* ── Loading overlay ──────────────────────────────────────────────────────── */
#loading-overlay {
  position:   fixed;
  inset:      0;
  display:    flex;
  flex-direction: column;
  align-items:    center;
  justify-content: center;
  gap:        14px;
  background: var(--bg);
  z-index:    999;
  font-size:  13px;
  color:      var(--text-muted);
}
/* ── Animations ───────────────────────────────────────────────────────────── */
@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fade-in 180ms ease-out forwards; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ── App shell ────────────────────────────────────────────────────────────── */
#app {
  max-width:  1080px;
  margin:     0 auto;
  padding:    24px 20px 0; /* No bottom padding here, we use margin on main */
  min-height: 100dvh;
  display:    flex;
  flex-direction: column;
}

/* ── Main ─────────────────────────────────────────────────────────────────── */
.app-main {
  display:        flex;
  flex-direction: column;
  gap:            16px;
  flex:           1;
  padding-bottom: 24px; /* Ensure space before sticky footer */
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.app-header {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  gap:             12px;
  margin-bottom:   20px;
  flex-wrap:       wrap;
}
.header-brand {
  display:    flex;
  align-items: center;
  gap:        8px;
  color:      var(--primary);
  flex-shrink: 0;
}
.brand-icon  { flex-shrink: 0; color: inherit; }
.brand-name  {
  font-size:      13px;
  font-weight:    600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color:          inherit;
  white-space:    nowrap;
}
.header-right { display: flex; align-items: center; gap: 6px; }
.header-quick-actions {
  display:      flex;
  align-items:  center;
  gap:          4px;
  margin-right: 4px;
}
.header-quick-actions .icon-btn {
  color: var(--text-muted);
}
@media (hover: hover) and (pointer: fine) {
  .header-quick-actions .icon-btn:hover { color: var(--primary); background: var(--bg-hover); }
}

.header-quick-actions .quick-dropdown {
  right: auto;
  left: 0;
}

/* Quick Actions Dropdown */
.quick-action-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.quick-dropdown {
  position:       absolute;
  top:            100%;
  right:          0;
  margin-top:     8px;
  background:     var(--bg-surface);
  border:         1px solid var(--border-strong);
  border-radius:  var(--radius-sm);
  box-shadow:     var(--shadow);
  z-index:        1100; /* Above header */
  min-width:      150px;
  padding:        6px;
  display:        flex;
  flex-direction: column;
  gap:            2px;
}
.quick-dropdown[hidden] {
  display: none;
}
.quick-dropdown-item {
  display:         flex;
  align-items:     center;
  gap:             8px;
  width:           100%;
  text-align:      left;
  padding:         8px 12px;
  background:      none;
  border:          none;
  color:           var(--text);
  font-size:       13px;
  font-family:     inherit;
  cursor:          pointer;
  border-radius:   var(--radius-xs);
  transition:      background 0.1s;
  text-decoration: none;
}
.quick-dropdown-item svg { flex-shrink: 0; color: var(--text-muted); }
@media (hover: hover) and (pointer: fine) {
  .quick-dropdown-item:hover svg { color: var(--primary); }
}
@media (hover: hover) and (pointer: fine) {

  .quick-dropdown-item:hover { background: var(--bg-hover);
  color:      var(--primary); }

}

/* Icon button */
.icon-btn {
  display:         flex;
  align-items:     center;
  justify-content: center;
  width: 32px; height: 32px;
  background:      transparent;
  border:          none;
  border-radius:   var(--radius-sm);
  color:           var(--text-muted);
  cursor:          pointer;
  transition:      background 0.15s, color 0.15s;
  flex-shrink:     0;
}
@media (hover: hover) and (pointer: fine) {

  .icon-btn:hover { background: var(--bg-hover); color: var(--text); }

}
@media (hover: hover) and (pointer: fine) {

  .icon-btn-signout:hover { background: var(--danger-dim); color: var(--danger); }

}

/* ── User context card ────────────────────────────────────────────────────── */
.user-context-card {
  display:       flex;
  flex-wrap:     wrap;
  gap:           20px;
  padding:       14px 18px;
  background:    var(--bg-surface);
  border:        1px solid var(--border);
  border-radius: var(--radius);
  box-shadow:    var(--shadow-sm);
  margin:        12px 16px 20px 16px; /* Match roles-section margin */
  box-sizing:    border-box;
}
.uc-item {
  display:     flex;
  align-items: flex-start;
  gap:         8px;
  font-size:   13px;
  color:       var(--text-muted);
  flex-shrink: 0;
}
.uc-item svg { margin-top: 2px; flex-shrink: 0; }
.uc-label    { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); margin-bottom: 2px; }
.uc-value    { font-weight: 500; color: var(--text); }
.uc-mono     { font-family: ui-monospace, 'Cascadia Code', 'Fira Code', monospace; font-size: 11px; color: var(--text-muted); }

.uc-tenant-name {
  display:     block;
  font-size:   13px;
  font-weight: 500;
  color:       var(--text);
}
.uc-tenant-id {
  display:     block;
  font-family: ui-monospace, 'Cascadia Code', 'Fira Code', monospace;
  font-size:   11px;
  color:       var(--text-muted);
}
.uc-tenant-item {
  align-items: center;
  margin-left: auto;
  gap:         12px;
}
.uc-tenant-switch-btn {
  display:        inline-flex;
  align-items:    center;
  gap:            6px;
  padding:        7px 16px;
  background:     var(--primary-dim);
  color:          var(--primary);
  border:         1.5px solid var(--primary);
  border-radius:  100px;
  font-size:      12px;
  font-weight:    600;
  letter-spacing: 0.01em;
  cursor:         pointer;
  white-space:    nowrap;
  flex-shrink:    0;
  box-shadow:     0 1px 4px rgba(37, 99, 235, 0.18);
  transition:     background 0.15s, color 0.15s, box-shadow 0.15s, transform 0.15s;
}
@media (hover: hover) and (pointer: fine) {
  .uc-tenant-switch-btn:hover {
    background:  var(--primary);
    color:       #fff;
    box-shadow:  0 3px 12px rgba(37, 99, 235, 0.38);
    transform:   translateY(-1px);
  }
  .uc-tenant-switch-btn:active {
    transform:  translateY(0);
    box-shadow: 0 1px 4px rgba(37, 99, 235, 0.18);
  }
}

/* ── Tenant picker modal ─────────────────────────────────────────────────── */
.modal-sm { max-width: 420px; }

.tenant-picker-hint {
  font-size:  13px;
  color:      var(--text-muted);
  text-align: center;
  padding:    12px 0;
}
.tenant-picker-error { color: var(--danger); }

.tenant-item {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  width:           100%;
  padding:         10px 12px;
  background:      transparent;
  border:          1px solid var(--border);
  border-radius:   var(--radius-sm);
  cursor:          pointer;
  text-align:      left;
  color:           var(--text);
  gap:             12px;
  margin-bottom:   6px;
  transition:      background 0.12s, border-color 0.12s;
}
.tenant-item:last-child { margin-bottom: 0; }
@media (hover: hover) and (pointer: fine) {
  .tenant-item:not([disabled]):hover {
    background:    var(--bg-hover);
    border-color:  var(--border-strong);
  }
}
.tenant-item-current {
  border-color: var(--primary);
  background:   var(--bg-selected);
  cursor:       default;
  opacity:      0.8;
}
.tenant-item-info { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.tenant-item-name {
  font-size:     13px;
  font-weight:   600;
  white-space:   nowrap;
  overflow:      hidden;
  text-overflow: ellipsis;
}
.tenant-item-domain {
  font-size:  11px;
  color:      var(--text-muted);
  font-family: ui-monospace, 'Cascadia Code', 'Fira Code', monospace;
  white-space:   nowrap;
  overflow:      hidden;
  text-overflow: ellipsis;
}
.tenant-item-badge {
  font-size:      9px;
  font-weight:    700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding:        2px 6px;
  border-radius:  var(--radius-xs);
  background:     var(--primary-dim);
  color:          var(--primary);
  border:         1px solid var(--primary);
  white-space:    nowrap;
  flex-shrink:    0;
}
.tenant-item-switching {
  font-size:  12px;
  color:      var(--text-muted);
}

/* ── Help modal ───────────────────────────────────────────────────────────── */
.help-body              { gap: 0; }
[id^="help-content-"]   { display: flex; flex-direction: column; gap: 16px; }
.help-section           { display: flex; flex-direction: column; gap: 8px; }
.help-section-title     { font-size: 13px; font-weight: 600; color: var(--text); }
.help-section p         { font-size: 13px; color: var(--text-muted); line-height: 1.55; margin: 0; }

.help-eyebrow {
  font-size:      10px;
  font-weight:    700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color:          var(--primary);
}

/* Numbered steps */
.help-steps    { display: flex; flex-direction: column; gap: 10px; }
.help-step     { display: flex; gap: 12px; align-items: flex-start; }
.help-step-num {
  width:           22px; height: 22px; min-width: 22px;
  border-radius:   50%;
  background:      var(--primary-dim);
  color:           var(--primary);
  font-size:       11px; font-weight: 700;
  display:         flex; align-items: center; justify-content: center;
  margin-top:      1px;
}
.help-step-body  { display: flex; flex-direction: column; gap: 2px; }
.help-step-label { font-size: 13px; font-weight: 600; color: var(--text); }
.help-step-desc  { font-size: 12px; color: var(--text-muted); line-height: 1.5; }

/* Callout boxes */
.help-callout {
  display:       flex; gap: 10px;
  padding:       10px 12px;
  border-radius: var(--radius-sm);
  border-left:   3px solid var(--primary);
  background:    var(--primary-dim);
}
.help-callout--success              { border-left-color: var(--success); background: var(--success-dim); }
.help-callout-icon                  { flex-shrink: 0; margin-top: 1px; color: var(--primary); }
.help-callout--success .help-callout-icon { color: var(--success); }
.help-callout-body                  { display: flex; flex-direction: column; gap: 2px; }
.help-callout-title                 { font-size: 12px; font-weight: 700; color: var(--text); }
.help-callout-text                  { font-size: 12px; color: var(--text-muted); line-height: 1.5; }

/* Feature cards */
.help-feature-grid {
  display:               grid;
  grid-template-columns: 1fr 1fr;
  gap:                   8px;
}
.help-feature-card {
  display:        flex; flex-direction: column; gap: 5px;
  padding:        10px 12px;
  background:     var(--bg-raised);
  border:         1px solid var(--border);
  border-radius:  var(--radius-sm);
}
.help-feature-card--highlight              { border-color: var(--primary); background: var(--primary-dim); }
.help-feature-card--success                { border-color: var(--success); background: var(--success-dim); }
.help-feature-card--highlight .help-feature-icon { color: var(--primary); }
.help-feature-card--success   .help-feature-icon { color: var(--success); }
.help-feature-icon  { color: var(--text-muted); }
.help-feature-title { font-size: 12px; font-weight: 700; color: var(--text); }
.help-feature-desc  { font-size: 11px; color: var(--text-muted); line-height: 1.45; }

/* Token / data storage table */
.help-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.help-table th {
  text-align:     left; padding: 4px 8px 6px;
  font-size:      10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color:          var(--text-faint);
  border-bottom:  1px solid var(--border);
}
.help-table td {
  padding:        6px 8px;
  color:          var(--text-muted);
  border-bottom:  1px solid var(--border);
  vertical-align: top;
}
.help-table td:first-child   { color: var(--text); font-weight: 500; }
.help-table tr:last-child td  { border-bottom: none; }

/* Architecture flow */
.help-flow      { display: flex; flex-direction: column; gap: 4px; margin: 2px 0; }
.help-flow-item {
  display:     flex; align-items: center; gap: 8px;
  font-size:   12px; color: var(--text-muted); padding: 2px 0;
}
.help-flow-item::before {
  content: ''; width: 6px; height: 6px; min-width: 6px;
  border-radius: 50%; background: var(--primary); opacity: 0.7;
}

/* FAQ */
.help-faq      { display: flex; flex-direction: column; gap: 12px; }
.help-faq-item { display: flex; flex-direction: column; gap: 3px; }
.help-faq-q    { font-size: 13px; font-weight: 600; color: var(--text); }
.help-faq-a    { font-size: 12px; color: var(--text-muted); line-height: 1.55; }
.theme-option {
  display:    block;
  width:      100%;
  padding:    9px 14px;
  background: none;
  border:     none;
  color:      var(--text);
  cursor:     pointer;
  font-size:  13px;
  font-family: inherit;
  text-align: left;
  transition: background 0.1s;
}
@media (hover: hover) and (pointer: fine) {

  .theme-option:hover { background: var(--bg-hover); }

}
.theme-option.active { color: var(--primary); font-weight: 500; }



/* Progress bar - Hidden as we now use spinning refresh button with status tooltip */
.progress-bar {
  display: none !important;
}

/* Spinning animation for icon buttons */
.icon-btn.spinning svg {
  animation: spin 1s linear infinite;
}

/* Status tooltip for icon buttons with data-status */
.icon-btn[data-status] {
  position: relative;
}
@media (hover: hover) and (pointer: fine) {

  .icon-btn[data-status]:hover::after { content: attr(data-status);
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 5px 9px;
  border-radius: var(--radius-xs);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  z-index: 1000;
  margin-top: 6px;
  box-shadow: var(--shadow-md);
  pointer-events: none;
  animation: fade-in 0.15s ease-out; }

}

/* ── Roles sections ───────────────────────────────────────────────────────── */
.roles-section {
  display:        flex;
  flex-direction: column;
  margin:         12px 16px;
  background:     var(--bg-surface);
  border:         1px solid var(--border);
  border-radius:  var(--radius);
  box-shadow:     var(--shadow-md);
  overflow:       hidden;
}

.section-header {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  gap:             12px;
  padding:         12px 20px;
  background:      var(--bg-surface);
  border-bottom:   1px solid var(--border);
  flex-wrap:       wrap;
}
.roles-section.collapsed .section-header { border-bottom: none; }
.roles-section.collapsed .table-wrap     { display: none; }

.section-title-group {
  display:     flex;
  align-items: center;
  gap:         8px;
}
.section-title { font-size: 15px; font-weight: 600; }
.role-count    { font-size: 12px; color: var(--text-muted); }
.section-controls { display: flex; align-items: center; gap: 8px; }

.section-collapse-btn {
  display:         inline-flex;
  align-items:     center;
  justify-content: center;
  width:           24px;
  height:          24px;
  padding:         0;
  background:      transparent;
  border:          none;
  border-radius:   var(--radius-xs);
  color:           var(--text-muted);
  cursor:          pointer;
  flex-shrink:     0;
}
.section-collapse-btn svg {
  transition: transform 0.2s ease;
}
.roles-section.collapsed .section-collapse-btn svg {
  transform: rotate(-90deg);
}
@media (hover: hover) and (pointer: fine) {
  .section-collapse-btn:hover { background: var(--bg-hover); color: var(--text); }
}

/* Search input */
.search-input {
  width:         180px;
  height:        30px;
  padding:       0 10px;
  background:    var(--input-bg);
  border:        1px solid var(--input-border);
  border-radius: var(--radius-sm);
  color:         var(--text);
  font-size:     13px;
  font-family:   inherit;
  outline:       none;
  transition:    border-color 0.15s;
}
.search-input:focus { border-color: var(--primary); }
.search-input::placeholder { color: var(--text-faint); }

/* ── Table ────────────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.roles-table {
  width:           100%;
  border-collapse: collapse;
  font-size:       13px;
  table-layout:    fixed;
}
.roles-table thead th {
  position:       sticky;
  top:            0;
  z-index:        5;
  background:     var(--bg-raised);
  color:          var(--text-faint);
  font-size:      10px;
  font-weight:    700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding:        7px 10px;
  white-space:    nowrap;
  border-bottom:  1px solid var(--border-strong);
  text-align:     left;
}
.roles-table tbody td {
  padding:        9px 10px;
  border-bottom:  1px solid var(--border);
  vertical-align: middle;
}
.roles-table tbody tr:last-child td { border-bottom: none; }
@media (hover: hover) and (pointer: fine) {

  .roles-table tbody tr:hover td { background: var(--bg-hover); }

}
.roles-table tbody tr.row-selected td { background: var(--bg-selected); }

/* Column widths */
.col-cb      { width: 40px; text-align: center; padding: 0 !important; }
.col-type    { width: 78px; }
.col-role    { min-width: 180px; }
.col-policy  { width: 70px; text-align: center !important; }
.col-expires { width: 110px; white-space: nowrap; }
/* Expand column — only visible on mobile via media query override */
.col-expand  { width: 40px; text-align: center !important; padding: 0 4px !important; display: none; }

/* Expand toggle button (mobile) */
.expand-btn {
  display:         flex;
  align-items:     center;
  justify-content: center;
  width:           28px;
  height:          28px;
  margin:          0 auto;
  background:      none;
  border:          none;
  border-radius:   var(--radius-xs);
  color:           var(--text-faint);
  cursor:          pointer;
  transition:      color 0.15s;
}
@media (hover: hover) and (pointer: fine) {

  .expand-btn:hover { color: var(--primary); }

}
.expand-btn svg    { transition: transform 0.2s ease; }
.expand-btn.open svg { transform: rotate(180deg); }

/* Policy detail panel (revealed on mobile expand) */
.row-detail td { padding: 0 10px 10px !important; border-bottom: 1px solid var(--border); }
.policy-detail {
  display:               grid;
  grid-template-columns: auto 1fr;
  gap:                   5px 14px;
  padding:               10px 14px;
  background:            var(--bg-raised);
  border-radius:         var(--radius-sm);
  border:                1px solid var(--border);
  font-size:             12px;
  max-width:             100%;
  overflow-wrap:         break-word;
  word-break:            break-word;
  box-sizing:            border-box;
}
.pd-label { color: var(--text-muted); font-weight: 500; white-space: nowrap; }
.pd-value  { color: var(--text); overflow-wrap: break-word; word-break: break-word; }

/* Checkbox cell */
.cb-wrap {
  display:         flex;
  align-items:     center;
  justify-content: center;
  cursor:          pointer;
  padding:         6px;
  height:          100%;
}
.cb-disabled {
  cursor: not-allowed;
}
.cb-disabled input {
  pointer-events: none;
}
.cb-wrap input[type="checkbox"] {
  width: 15px; height: 15px;
  cursor:       pointer;
  accent-color: var(--primary);
  flex-shrink:  0;
}

/* Role cell: name + scope underneath */
.role-cell       { display: flex; flex-direction: column; gap: 2px; }
.role-name       { font-weight: 500; line-height: 1.3; }
.role-scope {
  font-size:   11px;
  font-style:  italic;
  color:       var(--text-muted);
  overflow:    hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width:   340px;
  line-height: 1.3;
}
.row-placeholder td {
  text-align: center;
  color:      var(--text-muted);
  padding:    28px !important;
  font-size:  13px;
}

/* ── Type badges ──────────────────────────────────────────────────────────── */
.type-badge {
  display:       inline-block;
  padding:       2px 6px;
  border-radius: var(--radius-xs);
  font-size:     10px;
  font-weight:   700;
  letter-spacing: 0.04em;
  white-space:   nowrap;
  user-select:   none;
}
.badge-entra { background: var(--badge-entra-bg); color: var(--badge-entra-fg); }
.badge-group { background: var(--badge-group-bg); color: var(--badge-group-fg); }
.badge-azure { background: var(--badge-azure-bg); color: var(--badge-azure-fg); }

/* ── Policy matrix indicators ─────────────────────────────────────────────── */
.pol-dot {
  display:         inline-flex;
  align-items:     center;
  justify-content: center;
  padding:         1px 7px;
  border-radius:   var(--radius-xs);
  font-size:       10px;
  font-weight:     700;
  letter-spacing:  0.02em;
  white-space:     nowrap;
  cursor:          default;
  user-select:     none;
}
.pol-required { background: var(--primary-dim); color: var(--primary); border: 1px solid var(--primary); }
.pol-warning  { background: var(--warning-dim); color: var(--warning); border: 1px solid var(--warning); }
.pol-danger   { background: var(--danger-dim);  color: var(--danger);  border: 1px solid var(--danger); }
.pol-purple   { background: var(--purple-dim);  color: var(--purple);  border: 1px solid var(--purple); }
.pol-auth-ctx { background: var(--danger-dim);  color: var(--danger);  border: 1px solid var(--danger); }
.pol-none     { color: var(--text-faint); font-size: 14px; line-height: 1; }
.pol-none-label {
  display: none;
  font-size: 10px;
  border: 1px dashed var(--border);
  padding: 1px 4px;
  border-radius: 4px;
  color: var(--text-faint);
  background: var(--bg-hover);
  text-transform: uppercase;
}
body.show-inactive-policies .pol-none-dash {
  display: none;
}
body.show-inactive-policies .pol-none-label {
  display: inline-block;
}

.pol-max      { font-size: 12px; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
/* MFA column can contain both an MFA pill and an AC pill */
.pol-mfa-cell { display: flex; flex-direction: column; align-items: center; gap: 3px; }

/* Pending approval badge */

.mobile-badge { display: none; }
.mobile-policy-strip { display: none; }
.pending-badge {
  display:       inline-block;
  margin-left:   5px;
  padding:       1px 5px;
  background:    var(--warning-dim);
  color:         var(--warning);
  border:        1px solid var(--warning);
  border-radius: var(--radius-xs);
  font-size:     9px;
  font-weight:   700;
  letter-spacing: 0.02em;
  vertical-align: middle;
  user-select:   none;
}

/* Awaiting-approval ghost rows in Active table */
.row-awaiting-approval { opacity: 0.6; }
.row-awaiting-approval input[type="checkbox"] { cursor: not-allowed; }
.awaiting-tag {
  display:        inline-block;
  align-self:     flex-start;
  margin-top:     3px;
  padding:        1px 6px;
  background:     var(--warning-dim);
  color:          var(--warning);
  border:         1px solid var(--warning);
  border-radius:  var(--radius-xs);
  font-size:      10px;
  font-weight:    700;
  letter-spacing: 0.02em;
  white-space:    nowrap;
  user-select:    none;
}

/* Expiry */
.expiry-timer    { display: block; font-variant-numeric: tabular-nums; font-size: 12px; color: var(--text-muted); }
.expiry-abs      { display: block; font-variant-numeric: tabular-nums; font-size: 10px; color: var(--text-faint); margin-top: 2px; }
.expiry-soon     { color: var(--warning) !important; }
.expiry-critical { color: var(--danger)  !important; }

/* ── Section action bar ───────────────────────────────────────────────────── */
.section-action-bar {
  display:     flex;
  align-items: center;
  gap:         10px;
  padding:     8px 20px;
  background:  var(--bg-selected);
  border-top:  1px solid var(--primary);
}
.selection-label { font-size: 13px; color: var(--text-muted); flex: 1; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display:         inline-flex;
  align-items:     center;
  justify-content: center;
  gap:             6px;
  padding:         7px 16px;
  border:          1px solid transparent;
  border-radius:   var(--radius-sm);
  font-size:       13px;
  font-weight:     500;
  font-family:     inherit;
  cursor:          pointer;
  white-space:     nowrap;
  transition:      filter 0.15s, background 0.15s, opacity 0.15s;
  min-height:      32px;
  text-decoration: none;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.btn-sm { font-size: 12px; padding: 5px 12px; min-height: 28px; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
@media (hover: hover) and (pointer: fine) {

  .btn-primary:not(:disabled):hover { background: var(--primary-hover); }

}
.btn-primary:not(:disabled):active { background: var(--primary-active); }
.btn-danger  { background: var(--danger);  color: #fff; border-color: var(--danger); }
@media (hover: hover) and (pointer: fine) {

  .btn-danger:not(:disabled):hover { filter: brightness(1.12); }

}
.btn-ghost   { background: transparent; color: var(--text-muted); border-color: transparent; }
@media (hover: hover) and (pointer: fine) {

  .btn-ghost:not(:disabled):hover { background: var(--bg-hover); color: var(--text); border-color: var(--border); }

}

/* ── Operation overlay ────────────────────────────────────────────────────── */
.op-overlay {
  position:        fixed;
  inset:           0;
  background:      var(--modal-overlay);
  display:         flex;
  align-items:     center;
  justify-content: center;
  padding:         16px;
  z-index:         400;
  backdrop-filter: blur(4px);
  animation:       op-fade-in 0.18s ease;
}
@keyframes op-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.op-panel {
  background:     var(--bg-surface);
  border:         1px solid var(--border-strong);
  border-radius:  var(--radius);
  box-shadow:     var(--shadow);
  width:          100%;
  max-width:      440px;
  max-height:     80dvh;
  display:        flex;
  flex-direction: column;
  overflow:       hidden;
  animation:      op-slide-in 0.2s ease;
}
@keyframes op-slide-in {
  from { transform: translateY(-12px); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

.op-header {
  display:     flex;
  align-items: center;
  gap:         12px;
  padding:     18px 20px 14px;
  flex-shrink: 0;
}
.op-title {
  font-size:   15px;
  font-weight: 600;
  margin:      0;
  flex:        1;
}

/* Spinner */
.op-spinner {
  display:       inline-block;
  width:         20px;
  height:        20px;
  border:        2.5px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation:     op-spin 0.7s linear infinite;
  flex-shrink:   0;
}
@keyframes op-spin {
  to { transform: rotate(360deg); }
}
.op-header.op-done .op-spinner {
  border:           2.5px solid var(--success);
  border-top-color: var(--success);
  animation:        none;
  /* checkmark via clip trick */
  background:       var(--success-dim);
}

/* Progress track */
.op-progress-track {
  height:     3px;
  background: var(--border);
  flex-shrink: 0;
  margin:     0 20px 14px;
  border-radius: 2px;
  overflow:   hidden;
}
.op-progress-fill {
  height:     100%;
  width:      0%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.35s ease, background 0.3s ease;
}
.op-progress-fill.op-fill-done { background: var(--success); }

/* Role list */
.op-role-list {
  list-style:  none;
  margin:      0;
  padding:     0 0 8px;
  overflow-y:  auto;
  flex:        1;
}
.op-role-item {
  display:         flex;
  align-items:     center;
  gap:             10px;
  padding:         7px 20px;
  border-top:      1px solid var(--border);
  font-size:       13px;
  transition:      background 0.15s;
}
.op-role-item:first-child { border-top: none; }
.op-role-info { flex: 1; min-width: 0; }
.op-role-name  { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.op-role-scope { font-size: 11px; color: var(--text-muted); font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Per-row status icon */
.op-status-icon {
  flex-shrink: 0;
  width:       18px;
  height:      18px;
  border:      2px solid var(--border-strong);
  border-top-color: var(--text-muted);
  border-radius: 50%;
  animation:   op-spin 0.7s linear infinite;
}
.op-status-icon.op-icon-ok {
  border:     2px solid var(--success);
  background: var(--success-dim);
  animation:  none;
  /* SVG checkmark */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%2310b981' d='M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.75.75 0 1 1 1.06-1.06L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 11px;
}
.op-status-icon.op-icon-fail {
  border:     2px solid var(--danger);
  background: var(--danger-dim);
  animation:  none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23ef4444' d='M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.75.75 0 1 1 1.06 1.06L9.06 8l3.22 3.22a.75.75 0 1 1-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 0 1-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 9px;
}
.op-status-icon.op-icon-pending {
  border:     2px solid var(--warning);
  background: var(--warning-dim);
  animation:  none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23f59e0b' d='M8 1a7 7 0 1 1 0 14A7 7 0 0 1 8 1zm0 3.5a.75.75 0 0 0-.75.75v3.5c0 .414.336.75.75.75h2.5a.75.75 0 0 0 0-1.5H8.75V5.25A.75.75 0 0 0 8 4.5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 13px;
}

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position:        fixed;
  inset:           0;
  background:      var(--modal-overlay);
  display:         flex;
  align-items:     center;
  justify-content: center;
  padding:         16px;
  z-index:         1300;
  backdrop-filter: blur(8px);
}
.modal {
  background:     var(--bg-surface);
  border:         1px solid var(--border-strong);
  border-radius:  var(--radius);
  box-shadow:     0 20px 48px -12px rgba(0,0,0,0.5);
  display:        flex;
  flex-direction: column;
  width:          100%;
  max-width:      520px;
  max-height:     90dvh;
  overflow:       hidden;
  animation:      fade-in 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-header {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  padding:         16px 24px;
  border-bottom:   1px solid var(--border);
  flex-shrink:     0;
}
.modal-title  { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.modal-close  { color: var(--text-muted); }
@media (hover: hover) and (pointer: fine) {

  .modal-close:hover { color: var(--text); background: var(--bg-hover); }

}

.modal-body   {
  flex:           1;
  overflow-y:     auto;
  padding:        24px;
  display:        flex;
  flex-direction: column;
  gap:            20px;
}
.modal-footer {
  display:         flex;
  justify-content: flex-end;
  gap:             10px;
  padding:         14px 24px;
  border-top:      1px solid var(--border);
  background:      var(--bg-surface);
  flex-shrink:     0;
}
.settings-modal-footer { justify-content: space-between; align-items: center; }
.settings-reset-wrap   { display: flex; align-items: center; gap: 10px; }
.settings-reset-confirm { display: flex; align-items: center; gap: 8px; }
.settings-reset-label  {
  font-size:   13px;
  font-weight: 500;
  color:       var(--text-muted);
  white-space: nowrap;
}
.modal-role-list {
  background:    var(--bg-raised);
  border:        1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height:    160px;
  overflow-y:    auto;
  padding:       6px 0;
}
.modal-role-item {
  display:     flex;
  align-items: center;
  flex-wrap:   wrap;
  gap:         7px;
  padding:     6px 14px;
  font-size:   13px;
}
.modal-role-scope { font-size: 11px; color: var(--text-muted); font-style: italic; }

/* Form */
.form-row       { display: flex; flex-direction: column; gap: 6px; }
.form-label     { font-size: 13px; font-weight: 500; }
.req-mark       { color: var(--danger); }
.duration-inputs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.duration-num {
  width:         52px;
  height:        32px;
  padding:       0 6px;
  background:    var(--input-bg);
  border:        1px solid var(--input-border);
  border-radius: var(--radius-sm);
  color:         var(--text);
  font-size:     13px;
  font-family:   inherit;
  text-align:    center;
  outline:       none;
}
.duration-num:focus { border-color: var(--primary); }
.duration-sep  { color: var(--text-muted); font-size: 13px; padding: 0 2px; }
.duration-hint { font-size: 11px; color: var(--warning); margin-left: 4px; }
.form-textarea, .form-input, .form-select {
  width:         100%;
  padding:       8px 10px;
  background:    var(--input-bg);
  border:        1px solid var(--input-border);
  border-radius: var(--radius-sm);
  color:         var(--text);
  font-family:   inherit;
  font-size:     13px;
  outline:       none;
  transition:    border-color 0.15s;
}
.form-select {
  height:       32px;
  padding:      0 10px;
  color-scheme: dark;
}
:root[data-theme="light"] .form-select {
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .form-select { color-scheme: light; }
}
.form-select option {
  background-color: var(--bg-surface);
  color:            var(--text);
}
.form-select option:checked {
  background-color: var(--primary);
  color:            #ffffff;
}
.form-textarea:focus, .form-input:focus, .form-select:focus { border-color: var(--primary); }
.form-select:disabled { opacity: 0.5; cursor: not-allowed; }
.form-textarea { resize: vertical; min-height: 72px; }
.scope-hint { font-size: 11px; color: var(--text-muted); }
.scope-hint-error { color: var(--danger); }

.azure-scope-row { gap: 8px; }
.azure-scope-list {
  display:        flex;
  flex-direction: column;
  gap:            8px;
}
.azure-scope-item {
  border:        1px solid var(--border);
  border-radius: var(--radius-sm);
  background:    var(--bg-raised);
  padding:       10px 12px;
  display:       flex;
  flex-direction: column;
  gap:           8px;
}
.azure-scope-head {
  display:         flex;
  align-items:     flex-start;
  justify-content: space-between;
  gap:             10px;
}
.azure-scope-role { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.azure-scope-name {
  font-size:     13px;
  font-weight:   500;
  white-space:   nowrap;
  overflow:      hidden;
  text-overflow: ellipsis;
}
.azure-scope-current {
  margin-top:    2px;
  color:         var(--text-muted);
  font-size:     11px;
  font-style:    italic;
  white-space:   nowrap;
  overflow:      hidden;
  text-overflow: ellipsis;
}
.azure-scope-toggle {
  display:     flex;
  align-items: center;
  gap:         6px;
  color:       var(--text-muted);
  font-size:   12px;
  white-space: nowrap;
  cursor:      pointer;
}
.azure-scope-toggle input { margin: 0; }
.azure-scope-controls {
  border-top:     1px solid var(--border);
  display:        flex;
  flex-direction: column;
  gap:            7px;
  padding-top:    8px;
}
.azure-scope-path {
  color:         var(--text-faint);
  font-size:     11px;
  overflow:      hidden;
  text-overflow: ellipsis;
  white-space:   nowrap;
}
.azure-scope-picker-row {
  display:     flex;
  align-items: center;
  gap:         6px;
}
.azure-scope-picker-row .form-select { min-width: 0; flex: 1; }
.scope-hint.scope-warning { color: var(--warning); }
.scope-hint.scope-error   { color: var(--danger); }

@media (max-width: 560px) {
  .azure-scope-head,
  .azure-scope-picker-row {
    align-items: stretch;
    flex-direction: column;
  }
  .azure-scope-toggle { align-self: flex-start; }
}

/* ── Toast notifications ──────────────────────────────────────────────────── */
#toast-container {
  position:   fixed;
  bottom:     20px;
  right:      20px;
  display:    flex;
  flex-direction: column;
  gap:        8px;
  max-width:  360px;
  z-index:    400;
  pointer-events: none;
}
.toast {
  display:       flex;
  align-items:   flex-start;
  gap:           10px;
  padding:       11px 12px 11px 16px;
  border-radius: var(--radius);
  font-size:     13px;
  line-height:   1.45;
  word-break:    break-word;
  pointer-events: auto;
  box-shadow:    var(--shadow);
  border:        1px solid;
  animation:     toast-in 0.2s ease;
}
.toast-msg     { flex: 1; white-space: pre-wrap; }
.toast-dismiss {
  flex-shrink:  0;
  display:      flex;
  align-items:  center;
  justify-content: center;
  width:        20px;
  height:       20px;
  margin-top:   1px;
  background:   none;
  border:       none;
  cursor:       pointer;
  color:        currentColor;
  opacity:      0.6;
  border-radius: var(--radius-xs);
  transition:   opacity 0.15s;
}
@media (hover: hover) and (pointer: fine) {

  .toast-dismiss:hover { opacity: 1; }

}
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }
.toast-info    { background: var(--bg-surface); border-color: var(--border-strong); color: var(--text); }
.toast-success { background: var(--success-dim); border-color: var(--success); color: var(--success); }
.toast-error   { background: var(--danger-dim);  border-color: var(--danger);  color: var(--danger); }
.toast-warning { background: var(--warning-dim); border-color: var(--warning); color: var(--warning); }

/* ── Footer ───────────────────────────────────────────────────────────────── */
.app-footer {
  display:     flex;
  align-items: center;
  padding:     8px 12px;
  margin-top:  auto;
  border-top:  1px solid var(--border);
  text-align:  center;
  position:    sticky;
  bottom:      0;
  background:  var(--bg);
  z-index:     50;
}
.footer-inner {
  display:         flex;
  flex-direction:  column;
  align-items:     center;
  justify-content: center;
  gap:             4px;
  width:           100%;
  min-width:       0;
  margin-bottom:   0;
}
.footer-line {
  display:         flex;
  align-items:     center;
  flex-wrap:       nowrap;
  gap:             8px;
  justify-content: center;
  min-width:       0;
  max-width:       100%;
  line-height:     1.15;
  white-space:     nowrap;
}
.footer-person {
  display:     flex;
  align-items: center;
  gap:         5px;
  min-width:   0;
}
.footer-person-name { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.footer-person-links { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.footer-person-links a {
  display:     flex;
  align-items: center;
  color:       var(--text-faint);
  transition:  color 0.15s;
}
@media (hover: hover) and (pointer: fine) {

  .footer-person-links a:hover { color: var(--primary); }

}
.footer-separator { color: var(--text-faint); font-size: 12px; flex-shrink: 0; }
.footer-landing {
  color:       var(--text-muted);
  font-size:   12px;
  transition:  color 0.15s;
}
@media (hover: hover) and (pointer: fine) {

  .footer-landing:hover { color: var(--primary); text-decoration: none; }

}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .app-footer { padding: 7px 10px; }
  .footer-inner { gap: 3px; }
  .footer-line { gap: 6px; }
  .footer-person { gap: 4px; }
  .footer-person-name,
  .footer-landing { font-size: 11px; }
  .footer-person-links svg { width: 12px; height: 12px; }
}

@media (max-width: 640px) {
  #app { padding: 14px 12px; }
  .section-header { padding: 10px 12px; }
  .section-controls { gap: 8px; }
  .search-input   { width: 110px; }
  
  /* Hide policy matrix columns — user can tap the expand chevron to see them */
  .col-policy     { display: none; }
  .col-type       { display: none; }
  
  /* Active table: uses fixed layout for strict width control as it has no detail rows */
  #active-table { table-layout: fixed !important; }
  #active-table .col-cb { width: 40px !important; }
  #active-table .col-role { width: auto; }
  #active-table .col-expires { width: 80px !important; }

  /* Eligible table: uses auto layout to support the colspan detail rows, but with constrained role width */
  #eligible-table { table-layout: auto !important; }
  #eligible-table .col-cb { width: 40px; }
  #eligible-table .col-expand { width: 40px; }
  #eligible-table .col-role { 
    max-width: calc(100vw - 160px); /* Leave room for checkbox and expand columns */
    width: auto;
  }

  .roles-section  { margin: 12px 4px; }
  .roles-table tbody td { padding: 8px 6px; }
  .roles-table thead th { padding: 6px 6px; }
  
  .role-name { 
    display: block;
    overflow: hidden; 
    text-overflow: ellipsis; 
    white-space: nowrap; 
    max-width: 100%;
  }
  
  .mobile-badge   { display: inline-block; margin-right: 5px; vertical-align: middle; }
  .mobile-policy-strip { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
  
  .cb-wrap        { padding: 10px; }
  .expand-btn     { width: 44px; height: 44px; }
  .expiry-abs     { display: none; }

  @media (max-width: 480px) {
    #profiles-btn .btn-text { display: none; }
    #profiles-btn { padding: 8px; }
    .section-controls { gap: 4px; }
  }

  /* Constrain the detail panel to the actual viewport width */
  .policy-detail  { max-width: calc(100vw - 24px); }
  
  :root { --footer-height: 54px; }

  /* Mobile footer: two author rows */
  .app-footer          { padding: 7px 8px; position: sticky; bottom: 0; background: var(--bg); z-index: 50; }
  .footer-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 0;
  }
  .footer-author-line {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    width: 100%;
  }
  .footer-site-line,
  .footer-separator { display: none; }
  .footer-person {
    justify-content: center;
    gap: 4px;
    min-width: 0;
  }
  .footer-person-name { font-size: 10px; line-height: 1; }
  .footer-person-links { gap: 3px; }
  .footer-person-links svg { width: 11px; height: 11px; }
  @media (hover: hover) and (pointer: fine) {

    .footer-website:hover { color: var(--primary); text-decoration: none; }

  }
  #toast-container { bottom: calc(var(--footer-height) + 10px); right: 10px; left: 10px; max-width: none; }
  .section-action-bar { padding: 8px 12px; }
}
@media (max-width: 380px) {
  .col-type { display: none; }
  .app-footer { padding: 6px; }
  .footer-inner,
  .footer-author-line { gap: 3px; }
  .footer-person { gap: 3px; }
  .footer-person-name { font-size: 9px; }
  .footer-person-links svg { width: 10px; height: 10px; }
}

/* ── Fade-in animation ────────────────────────────────────────────────────── */
@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}
.fade-in { animation: fade-in 0.25s ease both; }

/* ── Inline form validation ───────────────────────────────────────────────── */
.form-error {
  font-size:  12px;
  color:      var(--danger);
  margin-top: 2px;
}
.input-error {
  border-color: var(--danger) !important;
}
.input-error:focus {
  border-color: var(--danger) !important;
  box-shadow:   0 0 0 2px var(--danger-dim);
}

/* ── Consent banner ───────────────────────────────────────────────────────── */
.consent-banner {
  display:     flex;
  align-items: center;
  gap:         10px;
  padding:     10px 20px;
  background:  var(--warning-dim);
  border-bottom: 1px solid var(--warning);
  color:       var(--warning);
}
/* ── Form refinements ─────────────────────────────────────────────────────── */
.form-divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}
.schedule-toggle-row { margin-top: 6px; }
.schedule-toggle-btn { align-self: flex-start; }
.schedule-toggle-btn svg { flex-shrink: 0; }
.schedule-toggle-btn.active,
.schedule-toggle-btn[aria-pressed="true"] {
  color:        var(--primary);
  background:   var(--primary-dim);
  border-color: var(--primary);
}
.schedule-start-field {
  display:        flex;
  flex-direction: column;
  gap:            6px;
  width:          100%;
  max-width:      280px;
}
.schedule-start-input { max-width: 280px; }
.profile-save-toggle-row { margin-top: 4px; }

@media (max-width: 560px) {
  .schedule-toggle-btn,
  .schedule-start-field,
  .schedule-start-input {
    width:     100%;
    max-width: none;
  }
}

/* ── Settings modal ───────────────────────────────────────────────────────── */

/* Section row: left = title+desc, right = control */
.settings-row {
  display:         flex;
  align-items:     flex-start;
  justify-content: space-between;
  gap:             20px;
  flex-wrap:       wrap;
}
.settings-info { flex: 1; min-width: 160px; }
.settings-title { font-size: 13px; font-weight: 600; color: var(--text); }
.settings-desc  { font-size: 11px; color: var(--text-muted); margin-top: 3px; line-height: 1.4; }
.settings-hr {
  border:     none;
  border-top: 1px solid var(--border);
  margin:     12px 0;
}

/* Collapsible settings groups */
.settings-group-toggle {
  display:     flex;
  align-items: center;
  gap:         8px;
  width:       100%;
  padding:     8px 0;
  background:  none;
  border:      none;
  cursor:      pointer;
  font-size:   13px;
  font-weight: 600;
  color:       var(--text);
  text-align:  left;
}
.settings-group-toggle svg { transition: transform 0.2s ease; flex-shrink: 0; }
.settings-group.collapsed .settings-group-toggle svg { transform: rotate(-90deg); }
.settings-group-body { display: flex; flex-direction: column; gap: 16px; padding-top: 4px; }
.settings-group.collapsed .settings-group-body { display: none; }
@media (hover: hover) and (pointer: fine) {
  .settings-group-toggle:hover { color: var(--accent); }
}

/* Flag pills (PIM surfaces) */
.flag-pills { display: flex; flex-wrap: wrap; gap: 6px; flex-shrink: 0; }
.flag-pill {
  display:       inline-flex;
  align-items:   center;
  gap:           6px;
  padding:       5px 12px;
  border:        1px solid var(--border-strong);
  border-radius: 999px;
  background:    var(--bg-raised);
  color:         var(--text-muted);
  font-size:     12px;
  font-weight:   500;
  font-family:   inherit;
  cursor:        pointer;
  white-space:   nowrap;
  transition:    all 0.15s;
}
@media (hover: hover) and (pointer: fine) {

  .flag-pill:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-dim); }

}
.flag-pill.active { border-color: var(--primary); background: var(--primary); color: #fff; }
.flag-dot {
  width:         7px;
  height:        7px;
  border-radius: 50%;
  background:    rgba(148,163,184,0.5);
  flex-shrink:   0;
  transition:    background 0.15s;
}
.flag-pill.active .flag-dot { background: rgba(110,231,183,0.85); }

/* ── Filter bar ───────────────────────────────────────────────────────────── */
.filter-bar {
  display:       flex;
  flex-wrap:     wrap;
  align-items:   center;
  gap:           6px;
  padding:       8px 20px;
  background:    var(--bg-surface);
  border-bottom: 1px solid var(--border);
  box-shadow:    inset 0 1px 0 var(--border);
}
.filter-bar.filter-bar-hidden        { display: none; }
.roles-section.collapsed .filter-bar { display: none; }

/* Filter toggle button — funnel icon in section controls */
.filter-toggle-btn.active {
  color:      var(--primary);
  background: var(--primary-dim);
}

.filter-bar-group {
  display:     flex;
  flex-wrap:   wrap;
  align-items: center;
  gap:         4px;
}
.filter-bar-divider {
  width:       1px;
  height:      18px;
  background:  var(--border-strong);
  flex-shrink: 0;
  margin:      0 2px;
}

.filter-saved-pill { padding-right: 8px; gap: 5px; }

.filter-saved-pill:active { cursor: grabbing; }
.filter-saved-pill.dragging { opacity: 0.35; }
.filter-saved-pill.drag-over {
  outline:        2px solid var(--primary);
  outline-offset: 2px;
}

.filter-delete-confirm {
  display:     inline-flex;
  align-items: center;
  gap:         6px;
  font-size:   12px;
  font-weight: 500;
  color:       var(--text);
  white-space: nowrap;
  padding:     2px 4px;
}

.filter-pill-delete {
  display:         inline-flex;
  align-items:     center;
  justify-content: center;
  width:           16px;
  height:          16px;
  border-radius:   50%;
  flex-shrink:     0;
  opacity:         0.6;
  cursor:          pointer;
  transition:      opacity 0.1s, background 0.1s;
}
@media (hover: hover) and (pointer: fine) {
  .filter-pill-delete:hover                    { opacity: 1; background: rgba(255,255,255,0.18); }
  .flag-pill.active .filter-pill-delete:hover  { background: rgba(0,0,0,0.15); }
}
@media (max-width: 640px) {
  .filter-bar         { padding: 6px 12px; gap: 5px; }
  .filter-bar-divider { display: none; }
}

/* Default duration control */
.settings-dur-ctrl  { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.settings-dur-input { width: 72px !important; height: 32px; padding: 0 8px !important; text-align: center; }
.settings-dur-label { font-size: 13px; color: var(--text-muted); }

/* iOS-style toggle switch */
.toggle-switch {
  position:      relative;
  display:       inline-flex;
  align-items:   center;
  width:         44px;
  height:        24px;
  border-radius: 999px;
  border:        2px solid transparent;
  background:    var(--border-strong);
  cursor:        pointer;
  flex-shrink:   0;
  transition:    background 0.2s ease;
  outline:       none;
}
.toggle-switch.active { background: var(--primary); }
.toggle-switch:focus-visible { box-shadow: var(--focus-ring); }
.toggle-thumb {
  position:      absolute;
  top:           2px;
  left:          2px;
  width:         16px;
  height:        16px;
  border-radius: 50%;
  background:    #fff;
  box-shadow:    0 1px 3px rgba(0,0,0,0.3);
  transition:    transform 0.2s ease;
}
.toggle-switch.active .toggle-thumb { transform: translateX(20px); }

/* Theme pills */
.theme-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
}
.theme-card {
  display:       inline-flex;
  align-items:   center;
  padding:       5px 12px;
  background:    var(--bg-raised);
  border:        1px solid var(--border-strong);
  border-radius: 999px;
  color:         var(--text-muted);
  font-size:     12px;
  font-weight:   500;
  font-family:   inherit;
  cursor:        pointer;
  transition:    all 0.15s;
  white-space:   nowrap;
}
@media (hover: hover) and (pointer: fine) {

  .theme-card:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-dim); }

}
.theme-card.active { border-color: var(--primary); background: var(--primary); color: #fff; }

/* Flags list (legacy — kept for compat) */
.flags-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}
.flag-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-surface);
  cursor: pointer;
}
@media (hover: hover) and (pointer: fine) {

  .flag-item:hover { background: var(--bg-hover); }

}
.flag-info { display: flex; flex-direction: column; gap: 2px; }
.flag-name { font-size: 13px; font-weight: 500; color: var(--text); }
.flag-desc { font-size: 11px; color: var(--text-muted); }
.flag-item input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

/* ── Profiles Modal ───────────────────────────────────────────────────────── */
.profile-item {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  transition: all 0.15s;
  overflow: hidden;
}
@media (hover: hover) and (pointer: fine) {

  .profile-item:hover { border-color: var(--primary); background: var(--bg-hover); }

}
.profile-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
}
.profile-info { flex: 1; min-width: 0; }
.profile-name { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.profile-meta { font-size: 12px; color: var(--text-muted); }
.profile-actions { display: flex; gap: 8px; align-items: center; }

/* Hover role list */
.profile-roles-peek {
  display: none;
  padding: 8px 16px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-raised);
}
@media (hover: hover) and (pointer: fine) {

  .profile-item:hover .profile-roles-peek { display: block; }

}
.peek-list { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.peek-item { font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.peek-item.missing { color: var(--text-faint); text-decoration: line-through; }
.peek-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }
.peek-item.missing .peek-dot { background: var(--text-faint); }

/* ── Azure Scope Controls ─────────────────────────────────────────────────── */
.azure-scope-item {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  overflow: hidden;
}
.azure-scope-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  gap: 12px;
  background: var(--bg-hover);
}
.azure-scope-role { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.azure-scope-name { font-size: 13px; font-weight: 600; color: var(--text); }
.azure-scope-current { font-size: 11px; color: var(--text-muted); }

.azure-scope-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}
.azure-scope-toggle input { width: 14px; height: 14px; accent-color: var(--primary); }

.azure-scope-controls {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}
.azure-scope-path {
  font-size: 10px;
  font-family: monospace;
  color: var(--text-faint);
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.azure-scope-picker-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.azure-scope-select { flex: 1; min-width: 0; }

.scope-hint { font-size: 11px; color: var(--text-muted); line-height: 1.4; }
.scope-hint-error { color: var(--danger); }

.profile-empty   {
  font-size:   13px;
  color:       var(--text-muted);
  text-align:  center;
  padding:     24px 0;
  line-height: 1.6;
}

/* ── Notification bell badge ──────────────────────────────────────────────── */
.notif-bell {
  position: relative;
  display:  flex;
  align-items: center;
}
.notif-badge {
  position:      absolute;
  top:           4px;
  right:         4px;
  width:         7px;
  height:        7px;
  background:    var(--danger);
  border-radius: 50%;
  pointer-events: none;
  font-size:     0;
}

/* ── Notification history list ────────────────────────────────────────────── */
.notif-empty {
  font-size:  13px;
  color:      var(--text-muted);
  text-align: center;
  padding:    32px 0;
}
.notif-list {
  display:        flex;
  flex-direction: column;
  gap:            6px;
}
.notif-item {
  display:        flex;
  align-items:    flex-start;
  gap:            14px;
  padding:        16px;
  border:         1px solid var(--border);
  border-radius:  var(--radius);
  background:     var(--bg-raised);
  font-size:      13px;
  line-height:    1.45;
  transition:     border-color 0.15s, background 0.15s;
  position:       relative;
}
@media (hover: hover) and (pointer: fine) {

  .notif-item:hover { border-color: var(--border-strong); background: var(--bg-hover); }

}

.notif-icon-wrap {
  flex-shrink:  0;
  width:        28px;
  height:       28px;
  display:      flex;
  align-items:  center;
  justify-content: center;
  border-radius: 50%;
  background:   var(--bg-surface);
  color:        var(--text-muted);
}
.notif-icon-success { color: var(--success); background: var(--success-dim); }
.notif-icon-error   { color: var(--danger);  background: var(--danger-dim); }
.notif-icon-warning { color: var(--warning); background: var(--warning-dim); }
.notif-icon-info    { color: var(--primary); background: var(--primary-dim); }

.notif-content { flex: 1; min-width: 0; }
.notif-row-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 2px; }
.notif-title { font-weight: 600; color: var(--text); font-size: 14px; }
.notif-time  { font-size: 11px; color: var(--text-faint); white-space: nowrap; margin-top: 2px; }
.notif-desc  { color: var(--text-muted); font-size: 13px; margin-bottom: 12px; word-break: break-word; white-space: pre-line; }
.notif-date  { display: none; } /* Hide the separate date line for a cleaner look like the reference */

.notif-activity {
  display:        flex;
  flex-direction: column;
  gap:            10px;
  margin-bottom:  12px;
}
.notif-meta-grid {
  display:   flex;
  flex-wrap: wrap;
  gap:       6px;
}
.notif-meta-pill {
  display:       inline-flex;
  align-items:   center;
  flex-wrap:     wrap;
  gap:           5px;
  max-width:     100%;
  padding:       4px 8px;
  border:        1px solid var(--border);
  border-radius: 999px;
  background:    var(--bg-surface);
  color:         var(--text-muted);
  font-size:     11px;
  line-height:   1.2;
  word-break:    break-word;
}
.notif-meta-pill span { color: var(--text-faint); }
.notif-role-list {
  list-style: none;
  display:    flex;
  flex-direction: column;
  gap:        6px;
}
.notif-role-row {
  display:     flex;
  align-items: flex-start;
  gap:         10px;
  padding:     8px 10px;
  border:      1px solid var(--border);
  border-radius: var(--radius-sm);
  background:  var(--bg-surface);
}
.notif-role-main { flex: 1; min-width: 0; }
.notif-role-name { color: var(--text); font-weight: 600; font-size: 12px; }
.notif-role-meta { color: var(--text-muted); font-size: 11px; margin-top: 2px; word-break: break-word; }
.notif-role-error { color: var(--danger); font-size: 11px; margin-top: 4px; word-break: break-word; }
.notif-role-status {
  flex-shrink: 0;
  min-width:   76px;
  padding:     3px 7px;
  border-radius: 999px;
  font-size:   10px;
  font-weight: 600;
  text-align:  center;
}
.notif-role-status-success { color: var(--success); background: var(--success-dim); }
.notif-role-status-error   { color: var(--danger);  background: var(--danger-dim); }
.notif-role-status-pending { color: var(--warning); background: var(--warning-dim); }
.notif-role-status-info    { color: var(--primary); background: var(--primary-dim); }

.notif-copy-btn {
  display:       inline-flex;
  align-items:   center;
  gap:           8px;
  padding:       6px 12px;
  background:    var(--bg-surface);
  border:        1px solid var(--border);
  border-radius: 6px;
  color:         var(--text-muted);
  font-size:     12px;
  font-weight:   500;
  font-family:   inherit;
  cursor:        pointer;
  transition:    all 0.15s ease;
}
@media (hover: hover) and (pointer: fine) {

  .notif-copy-btn:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border-strong); }

}
.notif-copy-btn svg { opacity: 0.7; }

.notif-debug {
  margin-top:    10px;
  padding:       10px;
  background:    var(--bg-surface);
  color:         var(--text-muted);
  font-family:   ui-monospace, 'Cascadia Code', monospace;
  font-size:     11px;
  border-radius: 6px;
  overflow-x:    auto;
  border:        1px solid var(--border);
  line-height:   1.6;
}

@media (max-width: 560px) {
  .notif-role-row { flex-direction: column; }
  .notif-role-status { min-width: 0; }
}

/* ── Duration slider ──────────────────────────────────────────────────────── */
.duration-slider {
  width:       100%;
  height:      4px;
  margin:      4px 0 10px;
  accent-color: var(--primary);
  cursor:      pointer;
  appearance:  none;
  -webkit-appearance: none;
  background:  var(--border-strong);
  border-radius: 2px;
  outline:     none;
}
.duration-slider::-webkit-slider-thumb {
  appearance:  none;
  -webkit-appearance: none;
  width:       16px;
  height:      16px;
  border-radius: 50%;
  background:  var(--primary);
  cursor:      pointer;
  border:      2px solid var(--bg-surface);
  box-shadow:  0 1px 3px rgba(0,0,0,0.3);
  transition:  transform 0.1s;
}
@media (hover: hover) and (pointer: fine) {

  .duration-slider::-webkit-slider-thumb:hover { transform: scale(1.15); }

}
.duration-slider::-moz-range-thumb {
  width:       16px;
  height:      16px;
  border-radius: 50%;
  background:  var(--primary);
  cursor:      pointer;
  border:      2px solid var(--bg-surface);
  box-shadow:  0 1px 3px rgba(0,0,0,0.3);
}
.duration-slider:focus-visible { box-shadow: var(--focus-ring); }

/* ── Section swap ─────────────────────────────────────────────────────────── */
.app-main.sections-swapped #section-active   { order: 2; }
.app-main.sections-swapped #section-eligible { order: 1; }


/* ── Duration preset buttons ──────────────────────────────────────────────── */
.duration-presets {
  display:   flex;
  flex-wrap: wrap;
  gap:       6px;
  margin-bottom: 8px;
}
.preset-btn {
  padding:       4px 10px;
  border:        1px solid var(--border-strong);
  border-radius: 999px;
  background:    transparent;
  color:         var(--text-muted);
  font-size:     12px;
  font-family:   inherit;
  font-weight:   500;
  cursor:        pointer;
  transition:    all 0.15s;
  white-space:   nowrap;
}
@media (hover: hover) and (pointer: fine) {

  .preset-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-dim); }

}
.preset-btn.active { border-color: var(--primary); background: var(--primary); color: #fff; }

/* ── Desktop zoom ─────────────────────────────────────────────────────────── */
/* Scale everything up ~10% on larger screens without affecting the
   mobile viewport. Phones already use device-width scaling via the
   viewport meta tag, so zoom is only applied at tablet/desktop widths. */
@media (min-width: 641px) {
  html { zoom: 1.1; }
}

/* ── Activation profiles ──────────────────────────────────────────────────── */
.profile-save-section {
  margin-bottom:  14px;
  padding-bottom: 14px;
  border-bottom:  1px solid var(--border);
  display:        flex;
  flex-direction: column;
  gap:            8px;
}
.profile-save-row {
  display: flex;
  gap:     8px;
}
.profile-save-extras {
  display:        flex;
  flex-direction: column;
  gap:            6px;
}
.profile-justification { min-height: 52px; resize: vertical; }
.profile-duration-row  { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.profile-list    { display: flex; flex-direction: column; gap: 8px; }
.profile-item    {
  display:       block;
  margin-bottom: 0;
  padding:       0;
  background:    var(--bg-raised);
  border:        1px solid var(--border);
  border-radius: var(--radius-sm);
  transition:    border-color 0.15s, background 0.15s;
}
@media (hover: hover) and (pointer: fine) {

  .profile-item:hover { border-color: var(--border-strong); }

}
.profile-main    { width: 100%; gap: 12px; }
.profile-info    { flex: 1; min-width: 0; }
.profile-name    {
  font-weight:   500;
  font-size:     13px;
  overflow:      hidden;
  text-overflow: ellipsis;
  white-space:   nowrap;
}
.profile-meta    { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.profile-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; margin-left: auto; }
.profile-activate-btn { white-space: nowrap; }
.profile-delete-btn { min-width: 34px; padding-inline: 10px; }
.profile-empty   {
  font-size:   13px;
  color:       var(--text-muted);
  text-align:  center;
  padding:     24px 0;
  line-height: 1.6;
}
/* Mobile User Context Card Toggle */
.uc-expand-btn {
  display: none;
  margin-left: auto;
  align-self: center;
  transition: transform 0.2s;
  color: var(--text-muted);
}
.uc-expand-btn:hover {
  color: var(--text);
  background: transparent;
}
@media (max-width: 640px) {
  .user-context-card {
    position: relative;
    padding-right: 48px;
    align-items: center;
  }
  .uc-collapsible {
    display: none;
  }
  .user-context-card.expanded .uc-collapsible {
    display: flex;
    width: 100%;
  }
  .uc-expand-btn {
    display: inline-flex;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
  }
  .user-context-card.expanded .uc-expand-btn {
    transform: translateY(-50%) rotate(180deg);
  }
}
