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

:root {
  --bg:          #0B1929;
  --surface:     #0F2035;
  --surface-2:   #142840;
  --border:      rgba(100,160,255,0.10);
  --border-soft: rgba(100,160,255,0.06);
  --text-1:      #E8EEF8;
  --text-2:      #7B8FAB;
  --text-3:      #3E5573;
  --accent:      #3D7FF5;
  --accent-dark: #2563EB;
  --accent-bg:   rgba(61,127,245,0.12);
  --sidebar-bg:  #071322;
  --sidebar-text:#A8BDDA;
  --sidebar-dim: #3E5573;
  --danger:      #F87171;
  --danger-bg:   rgba(248,113,113,0.10);
  --success:     #34D399;
  --success-bg:  rgba(52,211,153,0.10);
  --radius-sm:   7px;
  --radius:      10px;
  --radius-lg:   14px;
  --shadow-sm:   0 1px 4px rgba(0,0,0,0.5);
  --shadow:      0 4px 24px rgba(0,0,0,0.6), 0 0 0 1px rgba(100,160,255,0.06);
  --shadow-lg:   0 20px 60px rgba(0,0,0,0.7), 0 0 0 1px rgba(100,160,255,0.08);
}

html, #app { height: 100%; }

body {
  font-family: 'DM Sans', -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, #0F2035 0%, #0B1929 35%, #071322 100%);
  background-attachment: fixed;
}

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

h2 {
  font-size: 22px;
  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(61,127,245,0.18) 0%, transparent 70%);
  pointer-events: none;
}

.auth-brand-copy h1 {
  font-size: 36px;
  font-weight: 600;
  color: #FAF9F7;
  line-height: 1.2;
  letter-spacing: -0.5px;
  margin-bottom: 16px;
}

.auth-brand-copy p {
  color: var(--sidebar-dim);
  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;
}

.feature-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.auth-form-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  background: linear-gradient(160deg, #0F2035 0%, #0B1929 50%, #081525 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-3); font-size: 14px; margin-bottom: 28px; }

.auth-center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #0F2035 0%, #0B1929 50%, #081525 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: 'Instrument Serif', Georgia, serif;
  font-size: 18px;
  color: #FAF9F7;
  letter-spacing: -0.2px;
}

.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: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text-1);
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s;
}

.field-group input:focus,
.field-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,111,232,0.12);
}

.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: #FAF9F7;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.btn-primary:hover, .btn-primary-sm:hover { opacity: 0.9; box-shadow: 0 0 18px rgba(61,127,245,0.35); }
.btn-primary:disabled, .btn-primary-sm:disabled { opacity: 0.4; cursor: not-allowed; }
.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: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.btn-ghost:hover, .btn-ghost-sm:hover { background: var(--surface-2); color: var(--text-1); }
.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-dark);
  border: 1.5px solid rgba(59,111,232,0.2);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-accent-sm:hover { background: rgba(61,127,245,0.20); }

.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: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 660px;
  box-shadow: var(--shadow-lg);
  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(--text-1); 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: 220px 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;
  padding: 22px 16px;
  border-bottom: 1px solid rgba(100,160,255,0.08);
  font-size: 15px;
  font-weight: 600;
  color: #FAF9F7;
  letter-spacing: -0.2px;
}

.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(61,127,245,0.08); color: var(--sidebar-text); }
.nav-item.active { background: rgba(61,127,245,0.18); color: #E8EEF8; box-shadow: inset 2px 0 0 var(--accent); }
.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  padding: 16px 10px 20px;
  border-top: 1px solid rgba(100,160,255,0.08);
}

.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(61,127,245,0.08); color: var(--sidebar-text); }

/* ── Main content ── */
.main-content {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: linear-gradient(160deg, #0F2035 0%, #0B1929 40%, #081525 100%);
}

#archive-view,
#cases-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-3); margin-top: 4px; }

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

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

.search-inputs {
  flex: 1;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  align-items: center;
}

.search-input-wrap {
  position: relative;
  flex: 2;
  min-width: 160px;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 8px;
  color: var(--text-3);
  pointer-events: none;
}

.search-input-wrap input,
.filter-input {
  border: none;
  outline: none;
  font-size: 14px;
  font-family: inherit;
  background: transparent;
  color: var(--text-1);
}

.search-input-wrap input {
  width: 100%;
  padding: 7px 10px 7px 30px;
}

.filter-input {
  flex: 1;
  min-width: 100px;
  padding: 7px 10px;
  font-size: 13px;
}

.search-input-wrap input::placeholder,
.filter-input::placeholder { color: var(--text-3); }

.date-input { min-width: 130px; color: var(--text-2); }
.search-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ── Selection bar ── */
.selection-bar {
  margin: 0 28px 12px;
  background: var(--accent-bg);
  border: 1.5px solid rgba(59,111,232,0.2);
  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-dark); }

/* ── 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-3);
  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;
  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(61,127,245,0.06); border-left-color: rgba(61,127,245,0.25); }
.email-row.selected { background: rgba(61,127,245,0.08); border-left-color: var(--accent); box-shadow: inset 0 0 20px rgba(61,127,245,0.04); }

.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; }

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: 28px; height: 28px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ── 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: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  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(61,127,245,0.06); border-left-color: rgba(61,127,245,0.25); }
.case-row.selected { background: rgba(61,127,245,0.08); 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; }

.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: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
}

.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: var(--accent); background: var(--accent-bg); }

.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: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  max-height: 80vh;
  animation: slideUp 0.2s ease;
}

@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 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; }

.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(61,127,245,0.06); }
.reassign-user-row--current { background: var(--accent-bg); }
.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: var(--accent-bg); border-color: var(--accent); }
.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: #E8EDF7;
  color: #0B1929;
  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: var(--shadow);
}

/* ── 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: 180px 220px 180px 1fr;
  gap: 12px;
  padding: 10px 20px;
}

.audit-table-header {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  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); }

.audit-detail { font-size: 12px; color: var(--text-3); line-height: 1.5; word-break: break-word; }
.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;
}

/* ── 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: var(--surface-2); border-color: var(--accent); color: var(--accent-dark); }

/* ── 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: #4ADE80;
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.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: 11px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.06em; 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: var(--accent-dark); 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-3);
  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: 1.5px solid rgba(59,111,232,0.2);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--accent-dark);
  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-dark); }
.user-status--active::before   { background: var(--success); }
.user-status--inactive::before { background: var(--text-3); }
.user-status--invited::before  { background: var(--accent); }

.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-dark);
}

.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; }