/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0c1324;
  --surface:     #151b2d;
  --surface-2:   #191f31;
  --border:      rgba(69,70,77,0.20);
  --border-soft: rgba(69,70,77,0.10);
  --text-1:      #dce1fb;
  --text-2:      #c6c6cd;
  --text-3:      #909097;
  --accent:      #ffb77d;
  --accent-dark: #c36a00;
  --accent-bg:   rgba(255,183,125,0.10);
  --sidebar-bg:  #070d1f;
  --sidebar-text:#c6c6cd;
  --sidebar-dim: #909097;
  --danger:      #ffb4ab;
  --danger-bg:   rgba(255,180,171,0.10);
  --success:     #34D399;
  --success-bg:  rgba(52,211,153,0.10);
  --radius-sm:   8px;
  --radius:      12px;
  --radius-lg:   16px;
  --shadow-sm:   0 2px 8px rgba(0,0,0,0.5);
  --shadow:      0 0 40px rgba(0,0,0,0.5), 0 0 0 1px rgba(69,70,77,0.15);
  --shadow-lg:   0 0 60px rgba(0,0,0,0.6), 0 0 0 1px rgba(69,70,77,0.15);
}

html, #app { height: 100%; }

body {
  font-family: 'Manrope', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-1);
  font-size: 14px;
  line-height: 1.5;
  height: 100%;
  -webkit-font-smoothing: antialiased;
  background: linear-gradient(145deg, #151b2d 0%, #0c1324 40%, #070d1f 100%);
  background-attachment: fixed;
}

/* ── Typography ── */
h1, h2, h3 {
  font-family: 'Space Grotesk', sans-serif;
  letter-spacing: -0.02em;
}

h1.page-title {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

h2 {
  font-size: 22px;
  font-weight: 600;
}

h3 {
  font-size: 16px;
  font-weight: 600;
}

/* ── Auth screens ── */
#login-screen, #register-screen { height: 100%; display: none; }
#login-screen { display: flex; }

.auth-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
  width: 100%;
}

.auth-brand {
  background: var(--sidebar-bg);
  padding: 48px 56px;
  display: flex;
  flex-direction: column;
  gap: 48px;
  position: relative;
  overflow: hidden;
}

.auth-brand::before {
  content: '';
  position: absolute;
  top: -120px; right: -120px;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(255,183,125,0.12) 0%, rgba(123,208,255,0.06) 50%, transparent 70%);
  pointer-events: none;
}

.auth-brand-copy h1 {
  font-size: 36px;
  font-weight: 600;
  color: var(--text-1);
  line-height: 1.2;
  letter-spacing: -0.5px;
  margin-bottom: 16px;
}

.auth-brand-copy p {
  color: var(--sidebar-text);
  font-size: 16px;
  line-height: 1.6;
  margin-bottom: 32px;
}

.auth-brand-features { display: flex; flex-direction: column; gap: 12px; }

.feature-item {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--sidebar-text);
  font-size: 14px;
  line-height: 1.4;
}

.feature-icon {
  color: var(--accent);
  flex-shrink: 0;
  opacity: 0.85;
}

.auth-compliance-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid rgba(69,70,77,0.15);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--sidebar-dim);
  text-transform: uppercase;
}

.compliance-sep {
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--sidebar-dim);
  opacity: 0.5;
}

.feature-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(255,183,125,0.4);
}

.auth-form-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  background: linear-gradient(160deg, #151b2d 0%, #0c1324 50%, #070d1f 100%);
}

.auth-form-card { width: 100%; max-width: 400px; }

.auth-form-card.standalone {
  background: var(--surface);
  padding: 40px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.auth-form-card h2 { font-size: 24px; margin-bottom: 6px; }
.auth-form-sub { color: var(--text-2); font-size: 14px; margin-bottom: 28px; }

.auth-center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #151b2d 0%, #0c1324 50%, #070d1f 100%);
  padding: 24px;
}

.auth-alt { text-align: center; margin-top: 20px; font-size: 13px; color: var(--text-3); }
.auth-alt a { color: var(--text-1); font-weight: 500; text-decoration: none; }
.auth-alt a:hover { text-decoration: underline; }

/* ── Brand mark ── */
.brand-mark { display: flex; align-items: center; gap: 10px; }

.brand-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.3px;
}

.mb-24 { margin-bottom: 24px; }

/* ── Form fields ── */
.field-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field-group label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.field-hint { font-size: 12px; color: var(--text-3); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.req { color: var(--danger); }

.field-group input,
.field-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid rgba(69,70,77,0.20);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text-1);
  background: #070d1f;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field-group input:focus,
.field-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255,183,125,0.12), inset 0 0 8px rgba(255,183,125,0.04);
}

.field-group textarea { resize: vertical; }

.error-msg {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(248,113,113,0.25);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ── Buttons ── */
.btn-primary,
.btn-primary-sm {
  background: var(--accent);
  color: #4d2600;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 0 15px rgba(255,183,125,0.25);
}
.btn-primary:hover, .btn-primary-sm:hover { opacity: 0.92; box-shadow: 0 0 24px rgba(255,183,125,0.45); }
.btn-primary:disabled, .btn-primary-sm:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
.btn-primary { padding: 10px 22px; font-size: 14px; transition: opacity 0.15s, transform 0.1s; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary.full-width { width: 100%; margin-top: 4px; }
.btn-primary-sm { padding: 7px 16px; font-size: 13px; transition: opacity 0.15s; }

.btn-ghost,
.btn-ghost-sm {
  background: transparent;
  color: var(--text-2);
  border: 1px solid rgba(69,70,77,0.20);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn-ghost:hover, .btn-ghost-sm:hover { background: rgba(123,208,255,0.06); color: #7bd0ff; border-color: rgba(123,208,255,0.25); }
.btn-ghost { padding: 10px 20px; font-size: 14px; }
.btn-ghost-sm { padding: 6px 14px; font-size: 13px; text-decoration: none; display: inline-block; }

.btn-accent-sm {
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid rgba(255,183,125,0.25);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.btn-accent-sm:hover { background: rgba(255,183,125,0.18); box-shadow: 0 0 12px rgba(255,183,125,0.2); }

.btn-copy {
  background: var(--accent);
  color: white;
  border: none;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}
.btn-copy:hover { background: var(--accent-dark); }

/* ── Setup card ── */
.setup-card {
  background: rgba(46,52,71,0.6);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(69,70,77,0.20);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 660px;
  box-shadow: 0 0 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,183,125,0.06);
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.setup-card-header {
  padding: 32px 36px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 20px;
  flex-shrink: 0;
}

.setup-headline h2 { font-size: 20px; margin-bottom: 4px; }
.setup-domain-tag { font-size: 13px; color: var(--text-3); }

.setup-steps { padding: 28px 36px; display: flex; flex-direction: column; gap: 28px; }
.setup-step { display: flex; gap: 16px; }

.step-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; color: var(--text-2);
  flex-shrink: 0; margin-top: 1px;
}

.setup-step.done .step-num {
  background: var(--success-bg);
  border-color: #86EFAC;
  color: var(--success);
}

.step-body { flex: 1; min-width: 0; }
.step-label { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.step-desc { font-size: 13px; color: var(--text-2); margin-bottom: 12px; line-height: 1.6; }

.journal-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

.journal-box code {
  flex: 1;
  font-family: 'DM Mono', 'SF Mono', monospace;
  font-size: 13px;
  word-break: break-all;
}

.platform-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 14px;
  border-bottom: 1.5px solid var(--border);
}

.ptab {
  background: none; border: none;
  padding: 6px 14px 10px;
  font-size: 13px; font-weight: 500;
  cursor: pointer; color: var(--text-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1.5px;
  transition: color 0.15s, border-color 0.15s;
  font-family: inherit;
}
.ptab:hover { color: var(--text-1); }
.ptab.active { color: var(--accent); border-bottom-color: var(--accent); }

.platform-inst ol {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.6;
}

.platform-inst code {
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  display: inline-block;
  margin-top: 2px;
}

.setup-card-footer {
  padding: 20px 36px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  flex-shrink: 0;
}

/* ── App shell ── */
.app-shell {
  display: grid;
  grid-template-columns: 250px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  padding: 22px 16px;
  border-bottom: 1px solid rgba(69,70,77,0.15);
  font-size: 15px;
  color: var(--accent);
  letter-spacing: -0.3px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--sidebar-dim);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.nav-item svg { opacity: 0.7; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,183,125,0.08); color: var(--sidebar-text); }
.nav-item.active { background: rgba(255,183,125,0.12); color: var(--text-1); box-shadow: inset 2px 0 0 var(--accent); }
.nav-item.active svg { opacity: 1; }

.nav-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: rgba(255,183,125,0.12);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.nav-badge:empty { display: none; }

.sidebar-footer {
  padding: 16px 10px 20px;
  border-top: 1px solid rgba(69,70,77,0.15);
}

.sidebar-domain {
  font-size: 12px;
  color: var(--sidebar-dim);
  padding: 0 12px;
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-signout {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--sidebar-dim);
  background: none;
  border: none;
  cursor: pointer;
  width: 100%;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.nav-signout:hover { background: rgba(255,183,125,0.06); color: var(--sidebar-text); }

/* ── Main content ── */
.main-content {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: linear-gradient(160deg, #151b2d 0%, #0c1324 40%, #070d1f 100%);
}

#archive-view,
#cases-view,
#review-queues-view,
#audit-view,
#users-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 28px 28px 16px;
  flex-shrink: 0;
}

.page-subtitle { font-size: 13px; color: var(--text-2); margin-top: 4px; }

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 4px;
}

/* ── Search bar ── */
.search-bar {
  padding: 0 28px 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
}

.search-main-bar {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 24px;
  padding: 0 6px 0 16px;
  height: 46px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-main-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255,183,125,0.10), 0 0 20px rgba(255,183,125,0.06);
}

.search-bar-icon { color: var(--text-3); flex-shrink: 0; }

.search-main-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 15px;
  font-family: inherit;
  background: transparent;
  color: var(--text-1);
  padding: 0;
  min-width: 0;
}

.search-main-input::placeholder { color: var(--text-3); }

.search-bar-tools {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.search-tool-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 2px;
}

.search-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border: none;
  border-radius: 18px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}

.search-tool-btn:hover { background: rgba(255,255,255,0.06); color: var(--text-1); }
.search-tool-btn.active { color: var(--accent); }

.tool-btn-chevron { transition: transform 0.2s; flex-shrink: 0; }
.search-tool-btn.active .tool-btn-chevron { transform: rotate(180deg); }

.filter-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 9px;
  line-height: 1;
}

.search-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }

/* ── Filter panel ── */
.filter-panel {
  margin: 0 28px 12px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px 14px;
  animation: viewFadeIn 0.15s ease-out;
}

.filter-panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 10px 16px;
  align-items: end;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.filter-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.filter-field-input {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  color: var(--text-1);
  font-size: 13px;
  font-family: inherit;
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
  box-sizing: border-box;
}

.filter-field-input:focus { border-color: var(--accent); }
.filter-field-input::placeholder { color: var(--text-3); }
.filter-field-select { appearance: auto; cursor: pointer; }

.filter-clear-link {
  margin-top: 12px;
  gap: 5px;
  font-size: 12px;
  color: var(--text-3);
}
.filter-clear-link:hover { color: #7bd0ff; }

/* ── Archive stat badge ── */
.archive-stat {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 16px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
}

.archive-stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
}

.archive-stat-label {
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
}

.filter-checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
}

.filter-checkbox-label input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
}

.btn-link {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0;
  transition: color 0.15s;
}
.btn-link:hover { color: var(--accent); }

/* ── Saved searches ── */
.saved-search-wrap { position: relative; }

.saved-search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 280px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  animation: viewFadeIn 0.15s ease-out;
}

.saved-search-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}

.saved-search-list {
  max-height: 240px;
  overflow-y: auto;
}

.saved-search-empty {
  padding: 20px 14px;
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
}

.saved-search-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-soft);
  transition: background 0.12s;
}
.saved-search-item:hover { background: rgba(255,183,125,0.05); }
.saved-search-item:last-child { border-bottom: none; }

.saved-search-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.saved-search-desc {
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.saved-search-delete {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
}
.saved-search-delete:hover { background: var(--danger-bg); color: var(--danger); }

/* ── Selection bar ── */
.selection-bar {
  margin: 0 28px 12px;
  background: var(--accent-bg);
  border: 1px solid rgba(255,183,125,0.20);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.selection-label { flex: 1; font-size: 13px; font-weight: 500; color: var(--accent); }

/* ── Archive layout — resizable split ── */
.archive-layout {
  display: grid;
  grid-template-columns: 380px 8px 1fr;
  padding: 0 28px 28px;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.archive-resizer {
  width: 8px;
  cursor: col-resize;
  background: transparent;
  position: relative;
  flex-shrink: 0;
  z-index: 10;
  margin: 0 -2px;
}

.archive-resizer::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  background: var(--border);
  transition: background 0.15s, width 0.15s;
  border-radius: 2px;
}

.archive-resizer::before {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 4px; height: 24px;
  background-image: radial-gradient(circle, var(--text-3) 1px, transparent 1px);
  background-size: 4px 6px;
  background-repeat: repeat-y;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 1;
}

.archive-resizer:hover::after,
.archive-resizer.dragging::after { background: var(--accent); width: 3px; }

.archive-resizer:hover::before,
.archive-resizer.dragging::before { opacity: 1; }

.archive-layout.is-resizing { user-select: none; cursor: col-resize; }
.archive-layout.is-resizing * { pointer-events: none; }
.archive-layout.is-resizing .archive-resizer { pointer-events: all; }

/* ── Email list pane ── */
.email-list-pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1.5px solid var(--border);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
  background: var(--surface);
}

.list-header {
  display: grid;
  grid-template-columns: 32px 1fr 2fr 90px;
  gap: 8px;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1.5px solid var(--border);
  flex-shrink: 0;
}

.list-status {
  font-size: 12px;
  color: var(--text-3);
  padding: 8px 16px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-soft);
  min-height: 32px;
}

.list-body { overflow-y: auto; flex: 1; }

.email-row {
  display: grid;
  grid-template-columns: 32px 1fr 2fr 90px 44px;
  gap: 8px;
  padding: 11px 16px;
  align-items: center;
  cursor: pointer;
  border-bottom: 1px solid var(--border-soft);
  border-left: 3px solid transparent;
  transition: background 0.1s, border-color 0.1s;
}
.email-row:hover { background: rgba(255,183,125,0.04); border-left-color: rgba(255,183,125,0.25); }
.email-row.selected { background: rgba(255,183,125,0.07); border-left-color: var(--accent); box-shadow: inset 0 0 20px rgba(255,183,125,0.03); }

.col-check { display: flex; align-items: center; justify-content: center; }
.col-from { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-subject { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-date { font-size: 12px; color: var(--text-3); text-align: right; white-space: nowrap; }
.col-score { display: flex; align-items: center; justify-content: flex-end; }
.score-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(99,102,241,0.15);
  color: #818CF8;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

input[type="checkbox"].email-checkbox {
  width: 14px; height: 14px;
  cursor: pointer;
  accent-color: var(--accent);
  border-radius: 3px;
}

/* ── Email preview pane ── */
.email-preview-pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1.5px solid var(--border);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--surface);
}

/* ── Shared pane states ── */
.pane-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 14px;
  color: var(--text-3);
  font-size: 14px;
}

.pane-empty-icon {
  width: 72px; height: 72px;
  background: var(--surface-2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

.pane-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.spinner {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0%, var(--accent) 65%, transparent 100%);
  animation: spin 0.9s linear infinite;
  -webkit-mask: radial-gradient(farthest-side, transparent 48%, #fff 48%);
  mask: radial-gradient(farthest-side, transparent 48%, #fff 48%);
  filter: drop-shadow(0 0 6px var(--accent));
}

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

.btn-spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0%, #fff 65%, transparent 100%);
  animation: spin 0.8s linear infinite;
  -webkit-mask: radial-gradient(farthest-side, transparent 46%, #fff 46%);
  mask: radial-gradient(farthest-side, transparent 46%, #fff 46%);
  filter: drop-shadow(0 0 3px rgba(255,255,255,0.8));
  margin-right: 8px;
  vertical-align: middle;
}

/* ── Preview content ── */
.preview-header {
  padding: 20px 24px 16px;
  border-bottom: 1.5px solid var(--border);
  flex-shrink: 0;
}

.preview-subject {
  font-size: 16px;
  font-weight: 400;
  margin-bottom: 14px;
  line-height: 1.4;
}

.preview-meta { width: 100%; border-collapse: collapse; font-size: 13px; }
.preview-meta td { padding: 3px 0; vertical-align: top; }
.preview-meta td:first-child {
  width: 44px;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-right: 8px;
}

.preview-body { flex: 1; overflow: hidden; min-height: 0; }
.preview-body iframe { width: 100%; height: 100%; border: none; display: block; }

/* ── Attachments panel ── */
.preview-attachments {
  border-top: 1.5px solid var(--border);
  padding: 14px 24px;
  flex-shrink: 0;
  max-height: 55vh;
  overflow-y: auto;
}

.attach-header {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-2);
  margin-bottom: 10px;
}

.attach-list { display: flex; flex-direction: column; gap: 8px; }

/* ── Attachment item ── */
.attachment-item {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
  transition: border-color 0.15s;
}
.attachment-item:hover { border-color: var(--text-3); }

.att-main-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
}

.att-icon { font-size: 20px; flex-shrink: 0; line-height: 1; }
.att-info { flex: 1; min-width: 0; }

.att-name {
  display: block;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.att-meta { display: block; font-size: 11px; color: var(--text-3); margin-top: 2px; }
.att-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.att-loading { font-size: 12px; color: var(--text-3); font-style: italic; }
.att-unavailable { font-size: 12px; color: var(--text-3); }

/* ── Attachment inline preview (PDF.js canvas + images) ── */
.att-preview-panel {
  border-top: 1.5px solid var(--border);
  background: var(--surface-2);
}

.att-preview-panel img {
  display: block;
  max-width: 100%;
  height: auto;
  padding: 12px;
  margin: 0 auto;
}

.att-preview-panel canvas {
  display: block;
  max-width: 100%;
  margin: 0 auto;
  padding: 12px;
}

.att-pdf-status {
  font-size: 12px;
  color: var(--text-3);
  padding: 8px 12px;
  font-style: italic;
}

/* ── Preview footer ── */
.preview-footer {
  border-top: 1.5px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 12px;
}

.integrity-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--success-bg);
  color: var(--success);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  flex-shrink: 0;
}

.hash-val {
  font-family: 'DM Mono', 'SF Mono', monospace;
  font-size: 10px;
  color: var(--text-3);
  word-break: break-all;
  margin-left: 4px;
  display: none;
}

.preview-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ── State messages ── */
.state-message { text-align: center; padding: 48px 24px; color: var(--text-3); font-size: 14px; }

/* ── Cases layout ── */
.cases-layout {
  display: grid;
  grid-template-columns: 280px 340px 1fr;
  padding: 0 28px 28px;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.cases-list-pane {
  border: 1.5px solid var(--border);
  border-radius: var(--radius) 0 0 var(--radius);
  background: var(--surface);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.cases-list-body { overflow-y: auto; flex: 1; padding: 8px; }

.case-row {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-bottom: 2px;
  border-left: 3px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}
.case-row:hover { background: rgba(255,183,125,0.04); border-left-color: rgba(255,183,125,0.25); }
.case-row.selected { background: rgba(255,183,125,0.07); border-left-color: var(--accent); }
.case-row-title { font-weight: 500; font-size: 13px; margin-bottom: 5px; line-height: 1.4; }
.case-row-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 11px; color: var(--text-3); }

/* ── Status chips ── */
.status-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.status-open { background: rgba(74,222,128,0.12); color: #4ADE80; }
.status-under_review { background: rgba(251,191,36,0.12); color: #FCD34D; }
.status-closed { background: var(--surface-2); color: var(--text-3); }

/* ── Case detail pane ── */
.case-detail-pane {
  border: 1.5px solid var(--border);
  border-left: none;
  background: var(--surface);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#case-detail { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
#queue-detail,
#esc-queue-detail { display: flex; flex-direction: column; flex: 1; overflow: hidden; }

.case-detail-head { padding: 20px 20px 16px; border-bottom: 1.5px solid var(--border); flex-shrink: 0; }
.case-title-row { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.case-title-row h2 { font-size: 15px; flex: 1; line-height: 1.4; }
.case-meta-row { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--text-3); margin-bottom: 8px; }
.case-desc { font-size: 13px; color: var(--text-2); line-height: 1.5; margin-bottom: 10px; }
.case-status-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.case-status-select {
  padding: 6px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text-1);
  outline: none;
  cursor: pointer;
  color-scheme: dark;
}
.case-status-select:focus { border-color: var(--accent); }

.case-detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.case-section { display: flex; flex-direction: column; gap: 8px; }

.case-section-heading {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-2);
}

.case-email-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.case-email-item:hover,
.case-email-item.active { border-color: rgba(255,183,125,0.35); background: rgba(255,183,125,0.06); }

.case-email-info { flex: 1; min-width: 0; }
.case-email-subject { font-weight: 500; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.case-email-meta { font-size: 11px; color: var(--text-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.btn-remove {
  background: none; border: none;
  color: var(--text-3); font-size: 15px;
  cursor: pointer; padding: 4px 6px;
  border-radius: 4px; flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
}
.btn-remove:hover { background: var(--danger-bg); color: var(--danger); }

/* ── Notes ── */
.note-item {
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.note-header { display: flex; justify-content: space-between; margin-bottom: 4px; }
.note-author { font-weight: 600; font-size: 12px; }
.note-date { font-size: 11px; color: var(--text-3); }
.note-body { font-size: 13px; color: var(--text-2); line-height: 1.5; white-space: pre-wrap; }

.note-compose { display: flex; flex-direction: column; gap: 8px; }
.note-compose textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px; font-family: inherit;
  color: var(--text-1);
  resize: vertical; outline: none;
  background: var(--surface);
  transition: border-color 0.15s;
}
.note-compose textarea:focus { border-color: var(--accent); }

.case-detail-foot {
  border-top: 1.5px solid var(--border);
  padding: 12px 20px;
  display: flex;
  justify-content: flex-end;
  flex-shrink: 0;
}

/* ── Case preview pane ── */
.case-preview-pane {
  border: 1.5px solid var(--border);
  border-left: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--surface);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Modals ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(5,12,25,0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: rgba(46,52,71,0.6);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(69,70,77,0.20);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  box-shadow: 0 0 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,183,125,0.06);
  display: flex;
  flex-direction: column;
  max-height: 80vh;
  animation: modalSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-head {
  padding: 20px 24px 16px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1.5px solid var(--border);
  flex-shrink: 0;
}

.modal-head h3 { font-size: 18px; font-weight: 600; }

.modal-x {
  background: var(--surface-2); border: none;
  padding: 6px 8px; border-radius: var(--radius-sm);
  cursor: pointer; color: var(--text-2);
  display: flex; align-items: center;
  transition: background 0.12s;
}
.modal-x:hover { background: var(--border); }

.modal-body { padding: 20px 24px; overflow-y: auto; overflow-x: hidden; }

.modal-foot {
  padding: 16px 24px;
  border-top: 1.5px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
  flex-shrink: 0;
}

.case-picker { overflow-y: auto; max-height: 320px; padding: 10px; }

/* ── Reassign user list ── */
.reassign-user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-soft);
  transition: background 0.12s;
}
.reassign-user-row:hover { background: rgba(255,183,125,0.05); }
.reassign-user-row--current { background: rgba(255,183,125,0.10); }
.reassign-user-row:last-child { border-bottom: none; }

.case-picker-item {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1.5px solid var(--border);
  margin-bottom: 6px;
  transition: background 0.12s, border-color 0.12s;
}
.case-picker-item:hover { background: rgba(255,183,125,0.08); border-color: rgba(255,183,125,0.35); }
.case-picker-title { font-weight: 500; font-size: 14px; margin-bottom: 3px; }
.case-picker-meta { font-size: 12px; color: var(--text-3); }

/* ── Filter select ── */
.filter-select {
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text-1);
  outline: none;
  cursor: pointer;
  color-scheme: dark;
}
.filter-select:focus { border-color: var(--accent); }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: rgba(46,52,71,0.85);
  backdrop-filter: blur(16px);
  color: var(--text-1);
  border: 1px solid rgba(69,70,77,0.25);
  padding: 11px 22px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  z-index: 300;
  white-space: nowrap;
  box-shadow: 0 0 30px rgba(0,0,0,0.4);
}

/* ── View transitions ── */
#archive-view,
#cases-view,
#review-queues-view,
#audit-view,
#connections-view,
#users-view,
#billing-view {
  animation: viewFadeIn 0.25s ease-out;
}

@keyframes viewFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Email row entrance ── */
.email-row {
  animation: rowSlideIn 0.2s ease-out both;
}

.email-row:nth-child(1)  { animation-delay: 0ms; }
.email-row:nth-child(2)  { animation-delay: 25ms; }
.email-row:nth-child(3)  { animation-delay: 50ms; }
.email-row:nth-child(4)  { animation-delay: 75ms; }
.email-row:nth-child(5)  { animation-delay: 100ms; }
.email-row:nth-child(6)  { animation-delay: 125ms; }
.email-row:nth-child(7)  { animation-delay: 150ms; }
.email-row:nth-child(8)  { animation-delay: 175ms; }
.email-row:nth-child(9)  { animation-delay: 200ms; }
.email-row:nth-child(10) { animation-delay: 225ms; }
.email-row:nth-child(n+11) { animation-delay: 250ms; }

@keyframes rowSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Preview content fade ── */
#preview-content,
#case-email-content {
  animation: previewFadeIn 0.2s ease-out;
}

@keyframes previewFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Integrity badge pulse on load ── */
.integrity-badge {
  animation: badgePulse 0.6s ease-out;
}

@keyframes badgePulse {
  0%   { box-shadow: 0 0 0 0 rgba(52,211,153,0.35); }
  50%  { box-shadow: 0 0 0 6px rgba(52,211,153,0); }
  100% { box-shadow: none; }
}

/* ── Case row entrance ── */
.case-row {
  animation: rowSlideIn 0.2s ease-out both;
}

.case-row:nth-child(1)  { animation-delay: 0ms; }
.case-row:nth-child(2)  { animation-delay: 30ms; }
.case-row:nth-child(3)  { animation-delay: 60ms; }
.case-row:nth-child(4)  { animation-delay: 90ms; }
.case-row:nth-child(5)  { animation-delay: 120ms; }
.case-row:nth-child(n+6) { animation-delay: 150ms; }

/* ── Audit row entrance ── */
.audit-row {
  animation: rowSlideIn 0.15s ease-out both;
}

.audit-row:nth-child(1)  { animation-delay: 0ms; }
.audit-row:nth-child(2)  { animation-delay: 20ms; }
.audit-row:nth-child(3)  { animation-delay: 40ms; }
.audit-row:nth-child(4)  { animation-delay: 60ms; }
.audit-row:nth-child(5)  { animation-delay: 80ms; }
.audit-row:nth-child(n+6) { animation-delay: 100ms; }

/* ── Modal enhanced entrance ── */
.modal {
  animation: modalSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideUp {
  from { transform: translateY(16px) scale(0.98); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ── Audit Log ── */
.audit-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 28px 16px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.audit-search {
  flex: 1;
  min-width: 220px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 12px 0 32px;
  height: 38px;
  display: flex;
  align-items: center;
  position: relative;
}

.audit-search .search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); }

.audit-search input {
  border: none; outline: none;
  font-size: 13px; font-family: inherit;
  background: transparent;
  width: 100%; height: 100%;
}

.audit-table-wrap {
  margin: 0 28px 28px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* Shared grid layout for audit header + rows */
.audit-table-header,
.audit-row {
  display: grid;
  grid-template-columns: 210px 220px minmax(120px, auto) minmax(0, 1fr);
  gap: 12px;
  padding: 10px 20px;
}

.audit-table-header {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1.5px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}

.audit-table-body { overflow-y: auto; flex: 1; }

.audit-row {
  padding: 11px 20px;
  border-bottom: 1px solid var(--border-soft);
  align-items: start;
  transition: background 0.1s;
}
.audit-row:hover { background: var(--surface-2); }
.audit-row:last-child { border-bottom: none; }

.audit-timestamp { font-size: 12px; color: var(--text-3); font-family: 'DM Mono', 'SF Mono', monospace; white-space: nowrap; }
.audit-user { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.audit-event-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

/* Event chip colours */
.event-EMAIL_SEARCH,
.event-EMAIL_VIEW     { background: rgba(99,102,241,0.15); color: #818CF8; }
.event-EMAIL_DOWNLOAD { background: rgba(14,165,233,0.15); color: #38BDF8; }
.event-CASE_CREATE,
.event-CASE_UPDATE,
.event-USER_ACTIVATE  { background: rgba(74,222,128,0.12); color: #4ADE80; }
.event-CASE_EXPORT,
.event-EXPORT_TRIGGER { background: rgba(251,146,60,0.15); color: #FB923C; }
.event-USER_INVITE,
.event-USER_ROLE_CHANGE { background: rgba(167,139,250,0.15); color: #A78BFA; }
.event-USER_DEACTIVATE  { background: rgba(248,113,113,0.15); color: #F87171; }
.event-LOGIN,
.event-LOGOUT { background: var(--surface-2); color: var(--text-2); }
.event-ATTACHMENT_DOWNLOAD { background: rgba(14,165,233,0.15); color: #38BDF8; }
.event-EMAIL_MARK_REVIEWED,
.event-EMAIL_MARK_UNREVIEWED,
.event-EMAIL_REVIEW_NOTE { background: rgba(99,102,241,0.15); color: #818CF8; }
.event-REVIEW_QUEUE_CREATE,
.event-REVIEW_QUEUE_UPDATE,
.event-REVIEW_QUEUE_DELETE,
.event-REVIEW_QUEUE_MESSAGES_ADDED,
.event-REVIEW_QUEUE_MESSAGES_REMOVED,
.event-REVIEW_QUEUE_MESSAGE_FLAGGED,
.event-REVIEW_QUEUE_MESSAGE_UNFLAGGED { background: rgba(20,184,166,0.15); color: #2DD4BF; }
.event-EMAIL_ESCALATED,
.event-EMAIL_ESCALATION_REMOVED,
.event-ESCALATION_QUEUE_CREATE,
.event-ESCALATION_QUEUE_DELETE { background: rgba(245,158,11,0.15); color: #F59E0B; }
.event-LEGAL_HOLD_RELEASED { background: rgba(248,113,113,0.15); color: #F87171; }
.event-KEYWORD_SCAN_MATCH { background: rgba(245,158,11,0.15); color: #F59E0B; }
.event-KEYWORD_RULE_CREATE,
.event-KEYWORD_RULE_UPDATE { background: rgba(74,222,128,0.12); color: #4ADE80; }
.event-KEYWORD_RULE_DELETE { background: rgba(248,113,113,0.15); color: #F87171; }

.audit-detail { font-size: 12px; color: var(--text-3); line-height: 1.5; word-break: break-word; min-width: 0; }
.audit-detail strong { color: var(--text-2); font-weight: 500; }

.audit-status-bar {
  padding: 10px 20px;
  font-size: 12px;
  color: var(--text-3);
  border-top: 1px solid var(--border-soft);
  background: var(--surface-2);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.audit-status-count { font-weight: 500; }

.audit-integrity-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--success);
  font-size: 11px;
  font-weight: 600;
}

/* ── Reassign button ── */
.assign-current { color: var(--text-1); font-weight: 500; }

.btn-reassign {
  background: none;
  border: 1.5px solid var(--border);
  color: var(--text-2);
  padding: 2px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  margin-left: 8px;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn-reassign:hover { background: rgba(255,183,125,0.06); border-color: rgba(255,183,125,0.35); color: var(--accent); }

/* ── Connections ── */
.connections-grid { display: flex; flex-direction: column; gap: 20px; padding: 0 28px 28px; max-width: 760px; }

.conn-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow 0.15s;
}
.conn-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.3); }

.conn-card-head {
  display: flex; align-items: center; gap: 14px;
  padding: 20px 24px;
  border-bottom: 1.5px solid var(--border);
}

.conn-logo {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
}

.conn-card-info { flex: 1; min-width: 0; }
.conn-card-name { font-size: 15px; font-weight: 600; }
.conn-card-type { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.conn-status {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 20px;
  font-size: 12px; font-weight: 600; flex-shrink: 0;
}
.conn-status--active { background: rgba(74,222,128,0.12); color: #4ADE80; border: 1.5px solid rgba(74,222,128,0.25); }

.conn-status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #7bd0ff;
  animation: nebular-pulse 2s ease-in-out infinite;
}

@keyframes nebular-pulse {
  0%, 100% { box-shadow: 0 0 0px rgba(123,208,255,0); }
  50% { box-shadow: 0 0 8px rgba(123,208,255,0.7); }
}

.conn-card-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1.5px solid var(--border);
}

.conn-stat { padding: 16px 24px; border-right: 1.5px solid var(--border); }
.conn-stat:last-child { border-right: none; }

.conn-stat-value {
  font-size: 18px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.conn-stat-label {
  font-size: 11px; color: var(--text-3); margin-top: 2px;
  text-transform: uppercase; letter-spacing: 0.05em; font-weight: 500;
}

.conn-card-detail { padding: 18px 24px; border-bottom: 1.5px solid var(--border); }

.conn-detail-label {
  font-size: 12px; font-weight: 600; color: var(--text-2);
  letter-spacing: 0.02em; margin-bottom: 8px;
}

.conn-journal-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 10px;
}

.conn-journal-box code {
  font-family: 'DM Mono', 'SF Mono', monospace;
  font-size: 13px; flex: 1; word-break: break-all;
}

.conn-detail-hint { font-size: 12px; color: var(--text-3); line-height: 1.6; }
.conn-card-footer { padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; }

.conn-link {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 13px; color: #7bd0ff; text-decoration: none; font-weight: 500;
}
.conn-link:hover { text-decoration: underline; }

/* ── User management ── */
.users-role-legend {
  display: flex; align-items: center; gap: 6px;
  padding: 0 28px 14px;
  font-size: 12px; color: var(--text-3);
  flex-shrink: 0; flex-wrap: wrap;
}

.users-table-wrap {
  margin: 0 28px 28px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  display: flex; flex-direction: column;
  flex: 1; min-height: 0;
}

/* Shared grid for users table header + rows */
.users-table-header,
.user-row {
  display: grid;
  grid-template-columns: 2fr 140px 160px 110px 1fr;
  gap: 12px;
  padding: 10px 20px;
}

.users-table-header {
  font-size: 11px; font-weight: 600; color: var(--text-2);
  text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 1.5px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}

.users-table-body { overflow-y: auto; flex: 1; }

.user-row {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-soft);
  align-items: center;
  transition: background 0.1s;
}
.user-row:hover { background: var(--surface-2); }
.user-row:last-child { border-bottom: none; }
.user-row--inactive { opacity: 0.55; }

.user-cell { display: flex; align-items: center; }
.user-identity { gap: 12px; }

.user-avatar,
.mailbox-avatar {
  border-radius: 50%;
  background: var(--accent-bg);
  border: 1px solid rgba(255,183,125,0.20);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--accent);
  flex-shrink: 0; letter-spacing: 0.03em;
}
.user-avatar { width: 32px; height: 32px; font-size: 11px; }

.user-info { min-width: 0; }

.user-name {
  font-size: 13px; font-weight: 500;
  display: flex; align-items: center; gap: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.user-email {
  font-size: 12px; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px;
}

.user-self-badge {
  display: inline-block; padding: 1px 6px; border-radius: 10px;
  font-size: 10px; font-weight: 600;
  background: var(--surface-2); color: var(--text-3);
  border: 1px solid var(--border); letter-spacing: 0.02em; flex-shrink: 0;
}

.user-last-active { font-size: 12px; color: var(--text-3); }

.role-badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em; white-space: nowrap;
}
.role-admin      { background: rgba(251,191,36,0.12); color: #FCD34D; border: 1px solid rgba(251,191,36,0.25); }
.role-compliance { background: rgba(99,102,241,0.15); color: #818CF8; border: 1px solid rgba(99,102,241,0.25); }
.role-reviewer   { background: rgba(74,222,128,0.12); color: #4ADE80; border: 1px solid rgba(74,222,128,0.25); }
.role-viewer     { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }

.user-status {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 500;
}
.user-status::before {
  content: ''; width: 6px; height: 6px;
  border-radius: 50%; flex-shrink: 0;
}
.user-status--active   { color: var(--success); }
.user-status--inactive { color: var(--text-3); }
.user-status--invited  { color: var(--accent); }
.user-status--active::before   { background: var(--success); }
.user-status--inactive::before { background: var(--text-3); }
.user-status--invited::before  { background: #7bd0ff; }

.user-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.user-btn-danger { color: var(--danger) !important; border-color: rgba(220,38,38,0.2) !important; }
.user-btn-danger:hover { background: var(--danger-bg) !important; border-color: var(--danger) !important; }

/* ── Billing & Usage ── */
.billing-wrap { padding: 0 28px 28px; display: flex; flex-direction: column; gap: 24px; overflow-y: auto; flex: 1; }

.billing-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.billing-stat-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
}

.billing-stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-1);
  line-height: 1.1;
  margin-bottom: 6px;
}

.billing-plan-badge {
  font-size: 22px;
  color: var(--accent);
}

.billing-stat-label {
  font-size: 13px;
  color: var(--text-3);
}

.billing-period {
  font-size: 11px;
  color: var(--text-3);
}

.billing-section {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.billing-section--muted { opacity: 0.7; }

.billing-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1.5px solid var(--border);
}

.billing-section-title { font-size: 15px; font-weight: 600; color: var(--text-1); }
.billing-section-sub   { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.billing-empty {
  padding: 32px 24px;
  font-size: 13px;
  color: var(--text-3);
  text-align: center;
}

/* ── Mailbox table ── */
.mailbox-table { display: flex; flex-direction: column; }

.mailbox-header {
  display: grid;
  grid-template-columns: 1fr 140px;
  gap: 12px;
  padding: 10px 24px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--surface-2);
  border-bottom: 1.5px solid var(--border);
}

.mailbox-body { overflow-y: auto; max-height: 420px; }

.mailbox-row {
  display: grid;
  grid-template-columns: 32px 1fr 140px;
  gap: 12px;
  padding: 11px 24px;
  align-items: center;
  border-bottom: 1px solid var(--border-soft);
  transition: background 0.1s;
}
.mailbox-row:hover { background: var(--surface-2); }
.mailbox-row:last-child { border-bottom: none; }

.mailbox-avatar { width: 28px; height: 28px; font-size: 10px; }

.mailbox-address {
  font-size: 13px;
  color: var(--text-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mailbox-count {
  font-size: 12px;
  color: var(--text-3);
  text-align: right;
}

/* ── Coming soon block ── */
.billing-coming-soon {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 24px;
  color: var(--text-3);
}

.billing-coming-title { font-size: 14px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
.billing-coming-desc  { font-size: 13px; line-height: 1.6; }

/* ── Reviewed status ── */
.reviewed-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: rgba(80, 200, 140, 0.18);
  color: #50c88c;
  font-size: 10px;
  font-weight: 700;
  vertical-align: middle;
  margin-right: 2px;
  flex-shrink: 0;
}

.email-row.email-reviewed .col-subject { color: var(--text-3); }
.case-email-item.email-reviewed .case-email-subject { color: var(--text-3); }

/* Active state for mark-reviewed toggle button */
.btn-ghost-sm.active {
  color: #50c88c;
  border-color: rgba(80, 200, 140, 0.35);
  background: rgba(80, 200, 140, 0.07);
}
.btn-ghost-sm.active:hover {
  background: rgba(80, 200, 140, 0.12);
  border-color: rgba(80, 200, 140, 0.5);
}

/* Didn't Pass flag badge and button state */
.flag-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--danger);
  font-size: 11px;
  vertical-align: middle;
  margin-right: 2px;
  flex-shrink: 0;
}
.case-email-item.msg-flagged { border-color: rgba(255,180,171,0.3); }
.case-email-item.msg-flagged .case-email-subject { color: var(--danger); }
.btn-ghost-sm.flagged {
  color: var(--danger);
  border-color: rgba(255,180,171,0.35);
  background: var(--danger-bg);
}
.btn-ghost-sm.flagged:hover {
  background: rgba(255,180,171,0.18);
  border-color: var(--danger);
}

/* Reviewed filter checkbox row in advanced filters */
.filter-field-checkbox {
  display: flex;
  align-items: flex-end;
  padding-bottom: 2px;
}
.filter-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-2);
  user-select: none;
}
.filter-checkbox-label input[type="checkbox"] { cursor: pointer; width: 14px; height: 14px; accent-color: var(--accent); }

/* Case section heading with inline action button */
.case-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Review notes panel ── */
.preview-review-notes {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  background: var(--surface-2);
  flex-shrink: 0;
}
.review-notes-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.review-notes-empty { font-size: 12px; color: var(--text-3); margin-bottom: 10px; }
.review-note {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
}
.review-note-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.review-note-author { font-size: 11px; font-weight: 600; color: var(--text-2); }
.review-note-date   { font-size: 11px; color: var(--text-3); }
.review-note-text   { font-size: 13px; color: var(--text-1); white-space: pre-wrap; word-break: break-word; }
.review-notes-form  { display: flex; flex-direction: column; gap: 6px; }
.review-note-textarea {
  width: 100%;
  resize: vertical;
  min-height: 52px;
  padding: 7px 9px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-1);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-sizing: border-box;
  outline: none;
}
.review-note-textarea:focus { border-color: var(--accent); }
.review-notes-loading, .review-notes-error { font-size: 12px; color: var(--text-3); padding: 4px 0; }
/* ── Keyword rule cards ── */
.rule-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.rule-card-body { flex: 1; min-width: 0; }
.rule-card-title { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.rule-name { font-weight: 600; font-size: 13px; color: var(--text-1); }
.rule-status-badge {
  font-size: 11px; padding: 2px 7px; border-radius: 10px; flex-shrink: 0;
}
.rule-active   { background: var(--accent-muted); color: var(--accent); }
.rule-disabled { background: var(--surface-3); color: var(--text-3); }
.rule-keywords { font-size: 11px; color: var(--text-3); margin-bottom: 3px; }
.rule-kw-group { color: var(--text-2); }
.rule-kw-and   { color: var(--text-3); font-style: italic; }
.rule-kw-or    { color: var(--text-3); }
.rule-meta { font-size: 11px; color: var(--text-3); }

/* ── Rule ellipsis menu ── */
.rule-menu-wrap { position: relative; flex-shrink: 0; }
.rule-menu-btn { font-size: 16px; line-height: 1; letter-spacing: 2px; padding: 2px 6px; }
.rule-menu-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  min-width: 140px;
  z-index: 50;
  overflow: hidden;
}
.rule-menu-dropdown.open { display: block; }
.rule-menu-stat {
  padding: 8px 12px 6px;
  font-size: 11px;
  color: var(--text-3);
  border-bottom: 1px solid var(--border-soft);
}
.rule-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-1);
  background: none;
  border: none;
  cursor: pointer;
  transition: background 0.1s;
}
.rule-menu-item:hover { background: var(--surface-3); }
.rule-menu-danger { color: var(--danger); }
.rule-menu-danger:hover { background: rgba(248,113,113,0.1); }

/* ── Rule target-type toggle ── */
.rule-type-toggle {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}
.rule-type-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  font-size: 13px;
  color: var(--text-1);
  width: 100%;
  box-sizing: border-box;
}
.rule-type-option:has(input:checked) {
  border-color: rgba(255, 183, 125, 0.4);
  background: var(--accent-bg);
}
.rule-type-option input[type=radio] { accent-color: var(--accent); flex-shrink: 0; width: auto; }
.rule-type-option > div { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.rule-type-hint { display: block; font-size: 11px; color: var(--text-3); }
.rule-queues-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-left: 26px;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: 6px;
  border: 1px solid var(--border);
}
.rule-queues-list:empty { display: none; }
.rule-queues-list input[type=checkbox] { width: auto; accent-color: var(--accent); flex-shrink: 0; }

/* ── Route type label on rule card ── */
.rule-route-type {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.rule-route-review     { background: rgba(99,102,241,0.15); color: #818CF8; }
.rule-route-escalation { background: rgba(245,158,11,0.15); color: #F59E0B; }
