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

/* ─── Design tokens ─────────────────────────────────────────────────────────── */
:root {
  --bg:             #f1f5f9;
  --surface:        #ffffff;
  --surface-2:      #f8fafc;
  --border:         #e2e8f0;
  --border-strong:  #cbd5e1;
  --text:           #0f172a;
  --text-muted:     #64748b;
  --primary:        #2563eb;
  --primary-hover:  #1d4ed8;
  --primary-light:  #eff6ff;
  --primary-text:   #1e40af;
  --success:        #16a34a;
  --success-light:  #f0fdf4;
  --warning:        #d97706;
  --danger:         #dc2626;
  --danger-light:   #fef2f2;
  --shadow-sm:      0 1px 2px 0 rgb(0 0 0 / .05);
  --shadow-md:      0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);
  --shadow-lg:      0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);
  --shadow-xl:      0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1);
  --radius-sm:      6px;
  --radius-md:      8px;
  --radius-lg:      12px;
  --radius-xl:      16px;
  --font:           -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --t:              150ms ease;
  --header-h:       56px;
}

html { font-size: 15px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ─── Header ─────────────────────────────────────────────────────────────────── */
.header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  box-shadow: var(--shadow-sm);
}

.header-logo {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--text);
}
.header-logo h1 { font-size: 1.05rem; font-weight: 700; letter-spacing: -.02em; }
.header-actions { display: flex; align-items: center; gap: 4px; }

.branding-logo-img {
  height: 30px; width: auto; max-width: 140px;
  object-fit: contain; flex-shrink: 0;
}
.branding-preview-img {
  max-height: 64px; max-width: 220px;
  object-fit: contain;
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px;
  background: var(--surface-2);
}
.branding-preview-favicon {
  width: 32px; height: 32px; object-fit: contain;
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px;
  background: var(--surface-2);
}
.branding-preview-login-bg {
  max-height: 100px; max-width: 100%;
  object-fit: cover; border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.branding-empty {
  font-size: .8125rem; color: var(--text-muted);
}

/* ─── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: .875rem; font-weight: 500; font-family: var(--font);
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background var(--t), border-color var(--t), color var(--t), opacity var(--t);
  user-select: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

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

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }

.btn-outline { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-outline:hover:not(:disabled) { background: var(--surface-2); }

.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-sm  { padding: 5px 10px; font-size: .8125rem; }
.btn-icon { padding: 7px; }

/* ─── Filter bar ─────────────────────────────────────────────────────────────── */
.filter-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
}

.filter-group { display: flex; align-items: center; gap: 6px; }
.filter-group label { font-size: .8rem; font-weight: 600; color: var(--text-muted); white-space: nowrap; }

/* ─── Inputs & Selects ──────────────────────────────────────────────────────── */
.input, select.select, select.input {
  font-family: var(--font); font-size: .875rem; color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  outline: none;
  transition: border-color var(--t), box-shadow var(--t);
}
.input:focus, select.select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgb(37 99 235 / .12);
}
textarea.input { resize: vertical; line-height: 1.5; }

.select-wrapper { position: relative; display: inline-flex; align-items: center; }
.select-wrapper select { appearance: none; padding-right: 28px; cursor: pointer; }
.select-wrapper::after {
  content: '';
  position: absolute; right: 10px;
  width: 7px; height: 7px;
  border-right: 1.5px solid var(--text-muted);
  border-bottom: 1.5px solid var(--text-muted);
  transform: rotate(45deg) translateY(-3px);
  pointer-events: none;
}

.filter-select { min-width: 150px; }
.filter-date   { width: 128px; }
.filter-keyword { flex: 1 1 160px; }

.fulltext-toggle {
  display: flex; align-items: center; gap: 5px; cursor: pointer;
  font-size: .8125rem; font-weight: 500; color: var(--text-muted);
  user-select: none;
}
.fulltext-toggle input[type="checkbox"] {
  width: 15px; height: 15px; cursor: pointer; accent-color: var(--primary);
}

/* ─── Results header ─────────────────────────────────────────────────────────── */
.results-header {
  display: flex; align-items: center;
  padding: 10px 24px;
  font-size: .8125rem; color: var(--text-muted);
  gap: 8px;
}

/* ─── Results list ───────────────────────────────────────────────────────────── */
.results-list {
  padding: 0 24px 32px;
  display: flex; flex-direction: column; gap: 5px;
}

/* ─── Document card ──────────────────────────────────────────────────────────── */
.doc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color var(--t), box-shadow var(--t);
}
.doc-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.doc-card.open  { border-color: #93c5fd; box-shadow: 0 0 0 3px rgb(37 99 235 / .08); }

.doc-card-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  cursor: pointer; user-select: none;
}

/* Sender logo — spans full card-header height, sits between chevron and info */
.doc-logo {
  width: 40px; height: 40px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  align-self: stretch;
}

.doc-chevron {
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform var(--t);
}
.doc-card.open .doc-chevron { transform: rotate(90deg); }

.doc-info { flex: 1; min-width: 0; }

.doc-topic {
  font-size: .9375rem; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.doc-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 2px;
  font-size: .8rem; color: var(--text-muted);
}

.doc-type-tag {
  background: var(--primary-light); color: var(--primary-text);
  padding: 1px 7px; border-radius: 20px;
  font-size: .72rem; font-weight: 600;
}

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

.doc-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent; color: var(--text-muted);
  cursor: pointer;
  transition: background var(--t), color var(--t), border-color var(--t);
}
.doc-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.doc-btn.open-file:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.doc-btn.edit-btn:hover  { background: #fef3c7; color: #92400e; border-color: #fbbf24; }

/* Card body (expanded) */
.doc-card-body {
  display: none;
  padding: 0 14px 13px;
  border-top: 1px solid var(--border);
}
.doc-card.open .doc-card-body { display: block; }

.doc-summary {
  font-size: .875rem; color: var(--text-muted); margin-top: 10px; line-height: 1.6;
}

.doc-details {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px 16px;
  margin-top: 10px;
}

.doc-detail { display: flex; flex-direction: column; gap: 2px; }

.detail-label {
  font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted);
}
.detail-value { font-size: .875rem; color: var(--text); word-break: break-word; }

/* File link row inside card */
.doc-file-link {
  display: flex; align-items: center; gap: 8px;
  margin-top: 10px;
  padding: 7px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .8125rem;
}
.doc-file-link a {
  color: var(--primary); text-decoration: none;
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.doc-file-link a:hover { text-decoration: underline; }

.doc-file-path {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text-muted); font-size: .8125rem;
}

.btn-open-file {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 11px;
  background: var(--primary);
  color: #fff;
  border: none; border-radius: var(--radius-sm);
  font-size: .8rem; font-weight: 600;
  cursor: pointer; flex-shrink: 0;
  transition: background 150ms, transform 100ms;
}
.btn-open-file:hover  { background: var(--primary-hover); }
.btn-open-file:active { transform: scale(.97); }
.btn-open-file svg    { flex-shrink: 0; }

.cloud-badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 6px; border-radius: 20px;
  font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
  flex-shrink: 0;
}
.cloud-badge.dropbox  { background: #e0ecff; color: #0050d0; }
.cloud-badge.onedrive { background: #dceeff; color: #0050a0; }
.cloud-badge.url      { background: var(--surface-2); color: var(--text-muted); }

/* ─── Modal / Overlay ────────────────────────────────────────────────────────── */
.overlay {
  display: none; position: fixed; inset: 0;
  background: rgb(0 0 0 / .45);
  z-index: 200;
  align-items: center; justify-content: center;
  padding: 24px;
  backdrop-filter: blur(3px);
  animation: fadeIn 180ms ease;
}
.overlay.show { display: flex; }

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

.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%; max-width: 540px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  display: flex; flex-direction: column;
  animation: slideUp 200ms ease;
}

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

.modal-header {
  padding: 20px 24px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  position: sticky; top: 0;
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.modal-title { font-size: 1rem; font-weight: 700; }

.modal-close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: var(--text-muted);
  border-radius: var(--radius-sm); cursor: pointer;
  transition: background var(--t), color var(--t);
  flex-shrink: 0;
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }

.modal-body   { padding: 20px 24px; flex: 1; }
.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ─── Form fields ────────────────────────────────────────────────────────────── */
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field > label {
  display: block; font-size: .8125rem; font-weight: 600;
  color: var(--text); margin-bottom: 5px;
}
.field .input, .field select { width: 100%; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.field-hint { font-size: .75rem; color: var(--text-muted); margin-top: 4px; }

/* Cloud file-link section */
.cloud-field {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  background: var(--surface-2);
}

.cloud-provider-select {
  display: flex; gap: 6px; margin-bottom: 12px;
}

.cloud-opt {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  padding: 7px 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  text-align: center; cursor: pointer;
  font-size: .8125rem; font-weight: 500;
  transition: border-color var(--t), background var(--t), color var(--t);
}
.cloud-opt.active { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.cloud-opt input  { display: none; }

/* ─── Tabs ───────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}
.tab {
  padding: 9px 14px;
  font-size: .875rem; font-weight: 500;
  color: var(--text-muted); cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color var(--t), border-color var(--t);
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab:hover:not(.active) { color: var(--text); }

/* ─── Toast notifications ────────────────────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 300; pointer-events: none;
}

.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: .875rem; font-weight: 500;
  min-width: 240px; max-width: 360px;
  pointer-events: all;
  animation: toastIn 200ms ease;
  background: var(--text); color: #fff;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.warning { background: var(--warning); }

@keyframes toastIn {
  from { transform: translateX(80px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ─── Alert box ──────────────────────────────────────────────────────────────── */
.alert {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  margin-bottom: 14px;
}
.alert.error   { background: var(--danger-light);  color: var(--danger); }
.alert.success { background: var(--success-light); color: var(--success); }

/* ─── Spinner ────────────────────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
  margin: 24px auto; display: block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Empty state ────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-muted);
}
.empty-state svg { display: block; margin: 0 auto 14px; opacity: .25; }
.empty-state h3  { font-size: 1rem; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.empty-state p   { font-size: .875rem; }

/* ─── Cloud settings ─────────────────────────────────────────────────────────── */
.cloud-settings { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.cloud-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}
.cloud-card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }

.cloud-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.cloud-icon.dropbox  { background: #e0ecff; }
.cloud-icon.onedrive { background: #dceeff; }

.cloud-card-name { font-weight: 600; font-size: .9rem; }

.cloud-status {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .75rem; font-weight: 500; margin-top: 2px;
}
.cloud-status.connected    { color: var(--success); }
.cloud-status.disconnected { color: var(--text-muted); }
.cloud-status-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ─── Sender groups (admin) ──────────────────────────────────────────────────── */
.sender-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden; margin-bottom: 10px;
}
.sender-group-header {
  padding: 10px 14px;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: .875rem;
}
.sender-count { font-size: .75rem; color: var(--text-muted); font-weight: 400; }
.sender-group-body { padding: 10px 14px; }
.sender-variant {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 0; border-bottom: 1px solid var(--border);
  font-size: .875rem;
}
.sender-variant:last-child { border-bottom: none; }

/* ─── User list ──────────────────────────────────────────────────────────────── */
.user-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--border);
  font-size: .875rem;
}
.user-row:last-child { border-bottom: none; }
.user-name  { flex: 1; font-weight: 500; }
.user-email { color: var(--text-muted); flex: 1; }
.admin-badge {
  padding: 1px 6px; border-radius: 20px;
  background: #fef3c7; color: #92400e;
  font-size: .7rem; font-weight: 700;
}

/* ─── Browser (file picker) ──────────────────────────────────────────────────── */
.browser-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer; font-size: .875rem;
  transition: background var(--t);
}
.browser-item:hover { background: var(--surface-2); }
.browser-item.folder { font-weight: 500; }

/* ─── Sender logo (inline in card meta) ─────────────────────────────────────── */
.sender-logo-inline {
  width: 24px; height: 24px; object-fit: contain;
  border-radius: 3px; vertical-align: middle; flex-shrink: 0;
}

/* ─── Sender management (admin tab) ─────────────────────────────────────────── */
.sender-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.sender-logo-wrap { position: relative; flex-shrink: 0; }
.sender-logo-thumb {
  width: 36px; height: 36px; object-fit: contain;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.sender-logo-placeholder {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--border); border-radius: var(--radius-sm);
  color: var(--text-muted);
}
.sender-logo-upload {
  position: absolute; bottom: -4px; right: -4px;
  width: 16px; height: 16px;
  background: var(--primary); color: #fff;
  border-radius: 999px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem;
}
.sender-logo-upload:hover { background: var(--primary-hover); }

/* ─── Sender merge bar (checkbox-based multi-select) ────────────────────────── */
.sender-cb {
  width: 15px; height: 15px; flex-shrink: 0; cursor: pointer; accent-color: var(--primary);
}
.sender-merge-bar {
  position: sticky;
  bottom: -20px; /* flush with modal-body padding-bottom */
  z-index: 10;
  display: flex; align-items: center; gap: 8px; flex-wrap: nowrap;
  padding: 10px 12px;
  background: var(--surface);
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-sm);
  margin-top: 10px;
  box-shadow: 0 -4px 16px rgb(0 0 0 / .1);
}
.sender-merge-bar .select-wrapper {
  flex: 1 1 0;
  min-width: 0;
  max-width: 200px;
}
.sender-merge-bar .select-wrapper .select {
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.merge-bar-count {
  font-size: .8125rem; font-weight: 600; color: var(--primary); white-space: nowrap; flex-shrink: 0;
}
.merge-bar-label {
  font-size: .8rem; color: var(--text-muted); white-space: nowrap; flex-shrink: 0;
}

/* ─── Category management ────────────────────────────────────────────────────── */
.cat-color-input {
  width: 28px; height: 28px;
  padding: 1px; border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer; flex-shrink: 0;
  background: none;
}
.category-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 0; border-bottom: 1px solid var(--border);
}
.rule-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: var(--radius-sm);
  background: var(--surface-2); margin-bottom: 5px;
  font-size: .8125rem;
}
.rule-raw    { font-family: monospace; color: var(--danger); }
.rule-mapped { font-weight: 600; color: var(--primary); }

/* ─── Log section toggle ─────────────────────────────────────────────────────── */
.log-section-btn {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted); border-radius: var(--radius-sm);
  padding: 4px 12px; font-size: .8125rem; cursor: pointer;
  transition: background var(--t), color var(--t);
}
.log-section-btn:hover { background: var(--surface-2); color: var(--text); }
.log-section-btn.active {
  background: var(--primary); border-color: var(--primary);
  color: #fff;
}

/* ─── Activity log rows ──────────────────────────────────────────────────────── */
.activity-row {
  padding: 8px 10px; margin-bottom: 6px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface);
}
.activity-row.has-flags { border-left: 3px solid var(--warning); }
.activity-row-main {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px;
}
.activity-filename {
  font-size: .8125rem; font-weight: 500; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.activity-flags { display: flex; gap: 4px; flex-wrap: wrap; }
.activity-meta {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: .75rem; color: var(--text-muted);
}
.activity-ts { margin-left: auto; }
.meta-sep { opacity: .4; }

.flag-badge {
  font-size: .65rem; font-weight: 700; padding: 1px 6px;
  border-radius: 20px; white-space: nowrap;
}
.flag-duplicate    { background: #fef3c7; color: #92400e; }
.flag-no_sender    { background: #f1f5f9; color: #475569; }
.flag-no_date      { background: #f1f5f9; color: #475569; }
.flag-unknown_type { background: #fee2e2; color: #991b1b; }
.flag-warning      { background: #fef3c7; color: #92400e; }

/* ─── Ingest Log ─────────────────────────────────────────────────────────────── */
.log-entry {
  padding: 10px 12px; margin-bottom: 8px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  border-left: 3px solid var(--warning, #d97706);
  background: var(--surface);
}
.log-entry.acked {
  opacity: .55; border-left-color: var(--border);
}
.log-entry-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 5px;
}
.log-badge {
  font-size: .65rem; font-weight: 700; text-transform: uppercase;
  padding: 2px 6px; border-radius: 20px; flex-shrink: 0;
}
.log-warning { background: #fef3c7; color: #92400e; }
.log-error   { background: #fee2e2; color: #991b1b; }
.log-info    { background: #e0f2fe; color: #075985; }
.log-event   { font-size: .75rem; font-weight: 600; color: var(--text-muted); }
.log-message { font-size: .8125rem; color: var(--text); line-height: 1.5; }
.log-actions {
  display: flex; align-items: center; gap: 6px; margin-top: 8px;
  flex-wrap: wrap;
}

/* ─── Login page ─────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(145deg, #1e3a5f 0%, #2563eb 60%, #4f86f7 100%);
  padding: 24px;
}
.login-page.has-bg-image {
  background-size: cover;
  background-position: center;
  position: relative;
}
.login-page.has-bg-image::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
}
.login-page.has-bg-image .login-card {
  position: relative;
  z-index: 1;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%; max-width: 380px;
  padding: 40px 36px;
}

.login-logo {
  text-align: center; margin-bottom: 32px;
}
.login-logo svg { display: block; margin: 0 auto 12px; }
.login-logo h1  { font-size: 1.5rem; font-weight: 800; letter-spacing: -.03em; }
.login-logo p   { font-size: .875rem; color: var(--text-muted); margin-top: 4px; }
.branding-login-logo-img { display: block; margin: 0 auto 12px; max-height: 64px; max-width: 200px; object-fit: contain; }

.login-form .btn { width: 100%; justify-content: center; padding: 10px; margin-top: 4px; }

.login-footer {
  text-align: center; margin-top: 18px;
  font-size: .8125rem; color: var(--text-muted);
}
.login-footer a { color: var(--primary); text-decoration: none; }
.login-footer a:hover { text-decoration: underline; }

/* ─── Utilities ──────────────────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.hidden     { display: none !important; }

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .header-logo h1    { display: none; }
  .filter-bar        { gap: 8px; padding: 10px 12px; }
  .filter-select     { min-width: 110px; }
  .filter-date       { width: 110px; }
  .results-list,
  .results-header    { padding-left: 12px; padding-right: 12px; }
  .cloud-settings    { grid-template-columns: 1fr; }
  .field-row         { grid-template-columns: 1fr; }
  .login-card        { padding: 28px 20px; }
  .modal-header,
  .modal-body,
  .modal-footer      { padding-left: 16px; padding-right: 16px; }
}
