:root {
  --bg: #f8f9fc;
  --sidebar: #ffffff;
  --panel: #ffffff;
  --text: #1a1a2e;
  --muted: #8a8fa8;
  --accent: #5046e5;
  --accent-hover: #3f37c9;
  --ok: #0d9373;
  --ok-light: #ecfdf5;
  --warn: #d6293e;
  --warn-light: #fef2f2;
  --border: #ebebf0;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
  --radius: 10px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
}

html {
  font-size: 15px;
}

body {
  min-height: 100vh;
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: "Outfit", "Segoe UI", sans-serif;
}

/* ─── Layout ─── */

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 320px 1fr;
  transition: grid-template-columns 200ms ease;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 48px 1fr;
}

/* ─── Sidebar ─── */

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px 16px;
  gap: 4px;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow: hidden;
}

.sidebar-top {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-collapse-btn {
  flex-shrink: 0;
  display: grid;
  place-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, transform 200ms ease;
}

.sidebar-collapse-btn:hover {
  background: #f3f4f8;
  color: var(--text);
}

.sidebar-collapsed .sidebar-collapse-btn {
  transform: rotate(180deg);
}

/* Hide most sidebar content when collapsed */
.sidebar-collapsed .sidebar-section-label,
.sidebar-collapsed .sidebar-tree-panel,
.sidebar-collapsed .sidebar-bottom {
  display: none;
}

.sidebar-collapsed .brand-sub {
  display: none;
}

.sidebar-collapsed .sidebar-top {
  justify-content: center;
  border-bottom: none;
  padding-bottom: 8px;
}

.sidebar-collapsed .brand {
  display: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  margin: 0;
  font-weight: 700;
}

.brand-logo {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: block;
}

.brand-text {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.1;
}

.brand-name {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--muted);
  margin-top: 2px;
}

/* Auth gate / profile overlay: bigger logo + centered layout */
.auth-card .brand,
.profile-card .brand {
  justify-content: center;
}
.auth-card .brand-logo,
.profile-card .brand-logo {
  width: 48px;
  height: 48px;
}
.auth-card .brand-name,
.profile-card .brand-name {
  font-size: 26px;
}
.auth-card .brand-text,
.profile-card .brand-text {
  text-align: left;     /* keep stacked text left-aligned even when whole brand is centered */
}

.session-label {
  margin-top: 18px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--muted);
}

.session-title {
  display: block;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}

.session-sub {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-top: 1px;
}

/* ─── Sidebar section label ─── */

.sidebar-section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 4px 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  flex-shrink: 0;
}

/* ─── Sidebar tree ─── */

.sidebar-tree-panel {
  flex: 1;
  overflow-y: auto;
  padding: 4px 4px 4px 0;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: #d1d5db transparent;
}

.sidebar-tree-panel::-webkit-scrollbar {
  width: 4px;
}

.sidebar-tree-panel::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-tree-panel::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}

.sidebar-tree-panel::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

.folder-group {
  margin-bottom: 4px;
}

.folder-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 120ms ease;
  user-select: none;
}

.folder-header:hover {
  background: #f3f4f8;
}

.folder-chevron-btn {
  flex-shrink: 0;
  display: grid;
  place-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  color: var(--muted);
  transition: background 120ms ease;
}

.folder-chevron-btn:hover {
  background: #e5e7ef;
  color: var(--text);
}

.folder-chevron {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  transition: transform 150ms ease;
}

.folder-group.collapsed .folder-chevron {
  transform: rotate(-90deg);
}

.folder-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 5px;
  display: grid;
  place-content: center;
  color: #fff;
}

.folder-icon.ok { background: var(--ok); }
.folder-icon.warn { background: var(--warn); }
.folder-icon.folder-default { background: var(--accent); }

.folder-icon svg {
  width: 13px;
  height: 13px;
}

.folder-name {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  min-width: 0;
}

.folder-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.folder-children {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-left: 18px;
  border-left: 2px solid var(--border);
  margin-left: 16px;
  margin-top: 2px;
}

.folder-group.collapsed .folder-children {
  display: none;
}

.tree-file {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 120ms ease;
}

.tree-file:hover {
  background: #f3f4f8;
}

.tree-file.active {
  background: #eef0ff;
}

.tree-file-icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  display: grid;
  place-content: center;
}

.tree-file-icon.ok { background: var(--ok-light); color: var(--ok); }
.tree-file-icon.warn { background: var(--warn-light); color: var(--warn); }
.tree-file-icon.caution { background: #fef3c7; color: #b45309; }
.tree-file-icon.processing { background: #eef0ff; color: var(--accent); }
.tree-file-icon.info { background: #eef0ff; color: var(--accent); }
.tree-file-icon.error { background: var(--warn-light); color: var(--warn); }

.tree-file-name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-empty {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--muted);
}

/* ─── Sidebar category groups (Windows Explorer style) ─── */

.cat-group {
  margin-bottom: 3px;
}

.cat-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  transition: background 120ms ease;
}

.cat-header:hover {
  background: #f3f4f8;
}

.cat-chevron {
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  color: var(--muted);
  transition: transform 150ms ease;
}

.cat-group.collapsed .cat-chevron {
  transform: rotate(-90deg);
}

.cat-dot {
  flex-shrink: 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.cat-name {
  flex: 1;
  font-size: 13.5px;
  font-weight: 600;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.cat-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.cat-children {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-left: 14px;
  border-left: 2px solid var(--border);
  margin-left: 17px;
  margin-top: 2px;
  margin-bottom: 2px;
}

.cat-group.collapsed .cat-children {
  display: none;
}

.cat-processing .cat-name {
  color: var(--muted);
}

.cat-spinner {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border: 1.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.sf-header {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sf-header svg {
  flex-shrink: 0;
  color: var(--muted);
}

.tree-file-indented {
  padding-left: 14px;
}

.file-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: grid;
  place-content: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #fff;
}

.file-icon.pdf { background: #e74c3c; }
.file-icon.doc, .file-icon.docx { background: #2b6cb0; }
.file-icon.xls { background: #217346; }
.file-icon.html { background: #e44d26; }
.file-icon.txt { background: #6b7280; }
.file-icon.img { background: #d97706; }
.file-icon.other { background: #9ca3af; }

/* ─── Sidebar bottom ─── */

.sidebar-bottom {
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

.upload-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.upload-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 9px 6px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease;
}

.upload-button:hover {
  background: var(--accent-hover);
}

.upload-folder {
  background: #f3f4f8;
  color: var(--text);
  border: 1px solid var(--border);
}

.upload-folder:hover {
  background: #eaebf0;
}

.hidden-input { display: none; }

.sidebar-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  transition: background 120ms ease, color 120ms ease;
}

.sidebar-link:hover {
  background: #f3f4f8;
  color: var(--text);
}

/* ─── Content area ─── */

.content {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.topbar-nav {
  display: flex;
  gap: 24px;
}

.topbar-link {
  font-family: "Outfit", sans-serif;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  color: var(--muted);
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
  transition: color 120ms ease, border-color 120ms ease;
}

.topbar-link.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.topbar-link:hover {
  color: var(--text);
}

/* ─── Main body ─── */

.main-body {
  flex: 1;
  padding: 28px 36px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.section-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.overline {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.page-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ─── Upload page ─── */

.upload-page {
  align-items: center;
  justify-content: center;
  max-width: 640px;
  margin: 0 auto;
  text-align: center;
}

.upload-page .section-header {
  align-items: center;
}

.page-subtitle {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
  margin-top: 4px;
}

.company-field {
  width: 100%;
  text-align: left;
}

.company-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
}

.company-input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.company-input::placeholder {
  color: #b5b8cc;
}

.company-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(80, 70, 229, 0.12);
}

.company-input.input-error {
  border-color: var(--warn);
  box-shadow: 0 0 0 3px rgba(214, 41, 62, 0.12);
  animation: shake 300ms ease;
}

.company-input.input-error::placeholder {
  color: var(--warn);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

.drop-zone {
  width: 100%;
  border: 2px dashed var(--border);
  border-radius: 14px;
  background: #fbfbfe;
  padding: 48px 32px;
  cursor: pointer;
  transition: border-color 180ms ease, background 180ms ease;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--accent);
  background: #f0efff;
}

.drop-zone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.drop-zone-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(145deg, #eeecff, #ddd9ff);
  color: var(--accent);
  display: grid;
  place-content: center;
  margin-bottom: 4px;
}

.drop-zone-title {
  font-family: "Outfit", sans-serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.drop-zone-hint {
  font-size: 13px;
  color: var(--muted);
}

.drop-zone-formats {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.drop-zone-formats span {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 4px;
  background: #f0f0f5;
  color: var(--muted);
}

.upload-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.upload-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease, box-shadow 120ms ease, transform 80ms ease;
  text-decoration: none;
}

.upload-action-btn:active {
  transform: scale(0.98);
}

.upload-action-btn.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(80, 70, 229, 0.25);
}

.upload-action-btn.primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 6px 20px rgba(80, 70, 229, 0.35);
}

.upload-action-btn.secondary {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.upload-action-btn.secondary:hover {
  background: #f3f4f8;
  border-color: #d5d6e0;
}

.upload-size-hint {
  font-size: 15px;
}

/* ─── Document card ─── */

.document-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.empty-card p {
  color: var(--muted);
  font-size: 14px;
}

.doc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.doc-title {
  font-size: 20px;
  font-weight: 700;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 10px;
  white-space: nowrap;
}

.pill.ok {
  color: var(--ok);
  background: var(--ok-light);
}

.pill.warn {
  color: var(--warn);
  background: var(--warn-light);
}

.pill.caution {
  color: #b45309;
  background: #fef3c7;
}

.pill.progress {
  color: var(--accent);
  background: #eef0ff;
}

.doc-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  background: #f4f5f9;
  font-size: 12px;
  color: var(--muted);
}

.chip svg {
  flex-shrink: 0;
}

.view-report-btn {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

.view-report-btn:hover {
  background: #eef0ff;
  border-color: #c7d2fe;
}

/* ─── Validation timeline ─── */

.timeline {
  display: flex;
  flex-direction: column;
}

.timeline-item {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 14px;
  position: relative;
}

.timeline-track {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.timeline-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-content: center;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.timeline-dot.ok {
  background: var(--ok-light);
  color: var(--ok);
}

.timeline-dot.warn {
  background: var(--warn-light);
  color: var(--warn);
}

.timeline-dot svg {
  width: 13px;
  height: 13px;
}

.timeline-line {
  flex: 1;
  width: 2px;
  background: var(--border);
}

.timeline-line.ok { background: #bbf0de; }
.timeline-line.warn { background: #fecaca; }

.timeline-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 180ms ease;
}

.timeline-card:hover {
  box-shadow: var(--shadow-md);
}

.timeline-card.failed {
  border-left: 3px solid var(--warn);
}

.timeline-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.timeline-card-header h3 {
  font-size: 15px;
  font-weight: 600;
}

.timeline-card-desc {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

/* ─── Bottom row ─── */

.bottom-row {
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 14px;
}

.progress-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.progress-wrap {
  margin: 12px 0 8px;
  width: 100%;
  height: 8px;
  background: #ecedf2;
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 280ms ease;
}

.progress-text {
  font-size: 12px;
  color: var(--muted);
}

.score-card {
  background: linear-gradient(145deg, #5a50f0, #4338ca);
  color: #fff;
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-shadow: 0 8px 24px rgba(80, 70, 229, 0.28);
}

.score-icon {
  opacity: 0.7;
  margin-bottom: 4px;
}

.score-value {
  font-family: "Outfit", sans-serif;
  font-size: 36px;
  font-weight: 700;
  line-height: 1;
}

.score-label {
  margin-top: 4px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.85;
}

.muted {
  color: var(--muted);
  font-size: 12px;
  padding: 0 28px 20px;
}

/* ─── Page visibility ─── */

.hidden {
  display: none !important;
}

/* ─── Summary stats row ─── */

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  box-shadow: var(--shadow-sm);
  text-align: center;
}

.stat-card .stat-value {
  font-family: "Outfit", sans-serif;
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}

.stat-card .stat-label {
  margin-top: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.stat-ok .stat-value { color: var(--ok); }
.stat-warn .stat-value { color: var(--warn); }
.stat-accent .stat-value { color: var(--accent); }

/* ─── Summary table ─── */

.summary-table-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.summary-table thead {
  background: #f6f7fb;
}

.summary-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.summary-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.summary-table tbody tr:last-child td {
  border-bottom: none;
}

.summary-table tbody tr {
  transition: background 100ms ease;
}

.summary-table tbody tr:hover {
  background: #f9fafd;
}

.summary-table .cell-name {
  font-weight: 600;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-table .cell-score {
  font-weight: 700;
  font-family: "Outfit", sans-serif;
}

.summary-empty {
  padding: 24px 14px;
  text-align: center;
}

/* ─── Documents Checklist table ─── */

.checklist-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.checklist-overline {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin: 0;
}

.checklist-found-badge {
  font-size: 13px;
  color: var(--text);
}

.checklist-table .checklist-item-name {
  font-weight: 600;
  color: var(--fg);
}

.pill.checklist-not-found {
  color: #dc2626;
  background: #fef2f2;
}

.checklist-remark {
  font-size: 0.82rem;
  white-space: nowrap;
}
.remark-ok {
  color: var(--ok);
  font-weight: 600;
}
.remark-warn {
  color: var(--warn);
  font-weight: 600;
}

/* ─── Per-file report ─── */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  padding: 7px 12px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.back-link:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.report-back {
  margin-bottom: 12px;
}

.report-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.report-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.view-doc-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.view-doc-btn:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 2px 8px rgba(80, 70, 229, 0.25);
}

.report-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: grid;
  place-content: center;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.report-header-info {
  flex: 1;
  min-width: 0;
}

.report-file-name {
  font-size: 22px;
  font-weight: 700;
  word-break: break-word;
}

.report-file-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.report-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.report-section-title {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.detail-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}

.detail-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.detail-value {
  margin-top: 4px;
  font-size: 14px;
  font-weight: 600;
  word-break: break-all;
}

.report-checks {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.report-check-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}

.report-check-row.failed {
  border-left: 3px solid var(--warn);
}

.report-check-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.report-check-icon.ok {
  background: var(--ok-light);
  color: var(--ok);
}

.report-check-icon.warn {
  background: var(--warn-light);
  color: var(--warn);
}

.report-check-icon svg {
  width: 14px;
  height: 14px;
}

.report-check-body {
  flex: 1;
  min-width: 0;
}

.report-check-body h4 {
  font-size: 14px;
  font-weight: 600;
}

.report-check-body p {
  font-size: 13px;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.45;
}

.report-check-pill {
  flex-shrink: 0;
  margin-top: 2px;
}

.report-verdict {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  align-items: center;
}

.verdict-info h3 {
  font-size: 16px;
  font-weight: 700;
}

.verdict-info p {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.45;
}

.verdict-score {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #fff;
  flex-shrink: 0;
}

.verdict-score.ok {
  background: linear-gradient(145deg, #12b886, #0d9373);
  box-shadow: 0 6px 20px rgba(13, 147, 115, 0.3);
}

.verdict-score.warn {
  background: linear-gradient(145deg, #ef4444, #d6293e);
  box-shadow: 0 6px 20px rgba(214, 41, 62, 0.3);
}

.verdict-score.mixed {
  background: linear-gradient(145deg, #5a50f0, #4338ca);
  box-shadow: 0 6px 20px rgba(80, 70, 229, 0.28);
}

.verdict-pct {
  font-family: "Outfit", sans-serif;
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
}

.verdict-pct-label {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 2px;
  opacity: 0.85;
}

/* ─── Classification card (file report) ─── */

.classification-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.classification-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.classification-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.classification-full-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.classification-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.classification-meter {
  width: 100%;
  height: 6px;
  background: #ecedf2;
  border-radius: 999px;
  overflow: hidden;
}

.classification-meter-bar {
  height: 100%;
  border-radius: 999px;
  transition: width 300ms ease;
}

.classification-meter-text {
  font-size: 12px;
  color: var(--muted);
}

/* ─── Category parameter checklist ─── */

.param-checklist {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 4px;
}

.param-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  transition: background 100ms ease;
}

.param-row:hover {
  background: #f9fafd;
}

.param-row.warn {
  border-left: 3px solid var(--warn);
}

.param-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-content: center;
  flex-shrink: 0;
}

.param-icon.ok {
  background: var(--ok-light);
  color: var(--ok);
}

.param-icon.warn {
  background: var(--warn-light);
  color: var(--warn);
}

.param-icon.info {
  background: #eef0ff;
  color: var(--accent);
}

.param-icon.unknown {
  background: #f3f4f8;
  color: var(--muted);
}

.param-row.unknown {
  border-left: 3px solid var(--muted);
  opacity: 0.8;
}

.pill.unknown {
  color: var(--muted);
  background: #f3f4f8;
}

.param-icon svg {
  width: 12px;
  height: 12px;
}

.param-label {
  flex: 1;
  font-size: 13px;
  line-height: 1.4;
  min-width: 0;
}

.param-pill {
  flex-shrink: 0;
}

.param-value {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  max-width: 50%;
  text-align: right;
  word-break: break-word;
}

/* ─── Sidebar classification badge ─── */

.tree-cat-badge {
  flex-shrink: 0;
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 5px;
  border-radius: 4px;
  white-space: nowrap;
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Table classification pill ─── */

.table-cat-pill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

/* ─── Folder Report ─── */

.fr-hero {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 24px;
  background: linear-gradient(135deg, #f8f7ff 0%, #eef0ff 100%);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.fr-hero-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(80, 70, 229, 0.25);
}

.fr-hero-info {
  flex: 1;
  min-width: 0;
}

.fr-hero-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 2px;
}

.fr-hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 8px;
}

.fr-hero-meta span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--muted);
}

.fr-hero-meta svg {
  flex-shrink: 0;
}

.fr-hero-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
  align-self: center;
}

.fr-hero-actions .download-zip-hint {
  font-size: 11px;
  text-align: right;
}

/* Folder report stats */

.fr-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.fr-stat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

.fr-stat-card[data-status] {
  cursor: pointer;
}

.fr-stat-card[data-status]:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

.fr-stat-card.active {
  border-color: var(--accent);
  border-width: 2px;
  padding: 15px;
  box-shadow: var(--shadow-md);
}

/* Status filter panel (below folderStats) */
#folderStatusFilter {
  margin-top: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

#folderStatusFilter.hidden {
  display: none;
}

.status-filter-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: #fafbff;
}

.status-filter-label {
  font-weight: 700;
  font-size: 14px;
}

.status-filter-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: #eef0ff;
  padding: 2px 8px;
  border-radius: 999px;
}

.status-filter-close {
  margin-left: auto;
  display: grid;
  place-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 110ms ease, color 110ms ease;
}

.status-filter-close:hover {
  background: #eef0ff;
  color: var(--text);
}

.status-filter-body {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 360px;
  overflow-y: auto;
}

.status-filter-empty {
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.fr-stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-content: center;
  flex-shrink: 0;
}

.fr-stat-highlight {
  background: #eaedff;
  border-color: transparent;
  box-shadow: var(--shadow-sm);
  cursor: default;
}

.fr-stat-body {
  min-width: 0;
}

.fr-stat-value {
  font-family: "Outfit", sans-serif;
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}

.fr-stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-top: 3px;
  overflow-wrap: anywhere;
}

/* Folder report health card */

.fr-health-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.fr-health-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.fr-health-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  font-family: "Outfit", sans-serif;
}

.fr-health-badge {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.fr-health-bar-track {
  display: flex;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: #ecedf2;
  gap: 2px;
}

.fr-health-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 400ms ease;
}

.fr-health-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  color: var(--muted);
}

.fr-health-legend > span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.fr-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.fr-health-checks {
  margin-left: auto;
  font-weight: 600;
  color: var(--text);
}

/* Folder classification grid */

.fr-class-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}

.fr-class-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.fr-class-card.clickable {
  cursor: pointer;
}

.fr-class-card.clickable:hover {
  border-color: #c7d2fe;
  box-shadow: var(--shadow-md);
}

.fr-class-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fr-class-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.fr-class-name {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fr-class-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.fr-class-bar-track {
  width: 100%;
  height: 5px;
  background: #ecedf2;
  border-radius: 999px;
  overflow: hidden;
}

.fr-class-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 400ms ease;
}

.fr-class-pct {
  font-size: 11px;
  color: var(--muted);
}

.fr-class-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.fr-class-checks {
  font-size: 12px;
  color: var(--muted);
}

.fr-class-checks-pct {
  font-family: "Outfit", sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

/* ─── Detail grid wide item ─── */

.detail-item-wide {
  grid-column: 1 / -1;
}

/* ─── Cat chip in doc card ─── */

.cat-chip {
  font-weight: 600;
}

/* ─── Connection banner ─── */

.connection-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: #fef2f2;
  border-bottom: 1px solid #fecaca;
  color: var(--warn);
  font-size: 13px;
  font-weight: 500;
}

.connection-banner svg {
  flex-shrink: 0;
}

/* ─── Spinner ─── */

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--accent);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 600ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── Processing bar animation ─── */

.processing-bar {
  width: 30%;
  background: #9ca3af;
  animation: processing-slide 2s ease-in-out infinite alternate;
}

@keyframes processing-slide {
  0% { margin-left: 0; width: 30%; }
  100% { margin-left: 60%; width: 40%; }
}

.processing-hint {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

/* ─── Error card ─── */

.error-card {
  border-left: 4px solid var(--warn) !important;
}

.error-message {
  font-size: 13px;
  color: var(--warn);
  margin-top: 4px;
  line-height: 1.5;
}

/* ─── Info pill ─── */

.pill.info-pill {
  color: var(--accent);
  background: #eef0ff;
}

/* ─── Confidence reason ─── */

.confidence-reason {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  margin-top: 2px;
}

/* ─── Processing badge in hero meta ─── */

.processing-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef0ff;
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
}

.spinner-inline {
  width: 10px;
  height: 10px;
  border: 2px solid var(--accent);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 600ms linear infinite;
}

/* ─── Processing banner for folder report ─── */

.fr-processing-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  margin-top: 12px;
  background: linear-gradient(135deg, #eef0ff 0%, #f0eeff 100%);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 12px;
  position: relative;
  overflow: hidden;
}

.fr-processing-banner::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.05), transparent);
  animation: shimmer 2s ease-in-out infinite;
}

@keyframes shimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

.fr-processing-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--accent);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 600ms linear infinite;
  flex-shrink: 0;
}

.fr-processing-text {
  flex: 1;
  min-width: 0;
}

.fr-processing-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  margin: 0;
}

.fr-processing-sub {
  font-size: 12px;
  color: var(--muted);
  margin: 2px 0 0;
}

.fr-processing-bar-track {
  width: 80px;
  height: 6px;
  background: rgba(99, 102, 241, 0.15);
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
}

.fr-processing-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* ─── History page ─── */

.history-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.history-search-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.history-search-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(80, 70, 229, 0.12);
}

.history-search-wrap svg {
  flex-shrink: 0;
  color: var(--muted);
}

.history-search {
  border: none;
  outline: none;
  background: transparent;
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  font-size: 13px;
  color: var(--text);
  width: 100%;
}

.history-search::placeholder {
  color: #b5b8cc;
}

.history-clear-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--warn);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
  white-space: nowrap;
}

.history-clear-btn:hover {
  background: var(--warn-light);
  border-color: #fecaca;
}

/* ─── Reusable button system ────────────────────────────────────────────────
   Two variants used across History, Audit Log, and admin overlays. The
   existing .download-zip-btn / .auth-button still exist for backward
   compat — these new classes match their shape so the whole app feels
   consistent. */

.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  height: 36px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.btn-primary:disabled,
.btn-secondary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn-secondary {
  background: var(--panel);
  color: var(--text);
  border: 1px solid #d1d5db;
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg);
  border-color: #9ca3af;
}
.btn-primary svg,
.btn-secondary svg {
  flex-shrink: 0;
}

/* ─── Page-level loader (prominent spinner + message)
   Used by the History page and the Audit Log overlay while data is
   being fetched. */
.page-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 56px 24px;
  text-align: center;
}
.page-loader-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(80, 70, 229, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
.page-loader-text {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.02em;
  margin: 0;
}
/* When the loader appears inside a table cell (audit log) */
td .page-loader { padding: 32px 16px; }

/* ─── Date range picker — used on History page and Audit Log overlay ─── */
.date-range-picker {
  display: inline-flex;
  align-items: center;
  gap: 0;
  background: var(--panel);
  border: 1px solid #d1d5db;
  border-radius: 8px;
  height: 36px;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.date-range-picker:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(80, 70, 229, 0.12);
}
.date-field {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 0 12px;
  height: 100%;
  align-self: stretch;
  align-items: center;
}
.date-field + .date-field {
  border-left: 1px solid #e5e7eb;
}
.date-field-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.date-input {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  padding: 0;
  min-width: 130px;
  cursor: pointer;
}
.date-input:focus {
  outline: none;
}
.date-input::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.15s;
}
.date-input::-webkit-calendar-picker-indicator:hover { opacity: 1; }
/* Hide the browser-default placeholder text spacing — we use uppercase labels instead */
.date-input::-webkit-datetime-edit { color: var(--text); }
.date-input:invalid::-webkit-datetime-edit { color: var(--muted); }

/* ─── Audit log modal ─── */
.audit-panel { max-width: 1400px; width: 96vw; }
.audit-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  padding: 12px;
  background: var(--bg);
  border-radius: 8px;
  flex-wrap: wrap;
}
.audit-controls input[type="text"] {
  font-size: 14px;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-family: inherit;
  background: var(--panel);
  height: 36px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.audit-controls input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(80, 70, 229, 0.12);
}
.audit-search {
  flex: 1;
  min-width: 220px;
}
/* table-layout: fixed is required so:
   1. The Details column doesn't grow to accommodate long single-line JSON
      (which would push the whole table past the modal's right edge)
   2. max-width on cells is actually respected
   3. Expanding one row's Details doesn't affect the column width at all */
.audit-table {
  width: 100%;
  table-layout: fixed;
}
.audit-table td, .audit-table th {
  font-size: 12px;
  vertical-align: top;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Column widths — total budgets the modal's ~1340px usable width
   (1400px modal − padding). Details gets the remainder, ~540px. */
.audit-table th:nth-child(1), .audit-table td:nth-child(1) { width: 130px; }                              /* When */
.audit-table th:nth-child(2), .audit-table td:nth-child(2) { width: 200px; word-break: break-word; }      /* Actor (name + email) */
.audit-table th:nth-child(3), .audit-table td:nth-child(3) { width: 180px; }                              /* Action */
.audit-table th:nth-child(4), .audit-table td:nth-child(4) { width: 90px; }                               /* Resource type */
.audit-table th:nth-child(5), .audit-table td:nth-child(5) { width: 200px; }                              /* Resource ID */
.audit-table th:nth-child(6), .audit-table td:nth-child(6) { width: 110px; }                              /* IP */
/* 7th column (Details) takes the remaining width via fixed-layout's auto distribution. */

.audit-table td.audit-when    { white-space: nowrap; color: var(--muted); }
.audit-table td.audit-action  { font-family: "Source Sans 3", monospace; color: var(--text); white-space: nowrap; }
/* Resource ID column: monospace + muted + single-line ellipsis (the td-level
   overflow:hidden + text-overflow:ellipsis handles the truncation). Full ID
   is in the inner span's title attr for hover. */
.audit-table td.audit-resource-id-cell {
  font-family: "Source Sans 3", monospace;
  font-size: 11px;
  color: var(--muted);
}

/* Details column collapses to a single line by default — JSON metadata can be
   long and would otherwise blow up row height. Click the row to toggle. */
.audit-table td.audit-meta {
  font-family: "Source Sans 3", monospace;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
/* `.expandable` is added by JS only when the meta cell's content actually
   overflows its column — short metadata that fits on one line stays as a
   non-clickable static row with no chevron. Recomputed on render and on
   window resize. */
.audit-table tr.audit-row.expandable {
  cursor: pointer;
}
.audit-table tr.audit-row.expandable:hover {
  background: rgba(80, 70, 229, 0.04);
}
.audit-table tr.audit-row.expanded td.audit-meta {
  white-space: normal;
  word-break: break-all;     /* JSON has no spaces — break anywhere */
  text-overflow: clip;
}
.audit-table tr.audit-row.expandable td.audit-meta::before {
  content: "▸ ";
  color: var(--accent);
  font-family: monospace;
  margin-right: 4px;
}
.audit-table tr.audit-row.expandable.expanded td.audit-meta::before {
  content: "▾ ";
}

/* Session card */

.history-session-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.history-session-card:hover {
  border-color: #c7d2fe;
  box-shadow: var(--shadow-md);
}

.history-session-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px 10px;
}

.history-session-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #f8f7ff, #eef0ff);
  color: var(--accent);
  display: grid;
  place-content: center;
  flex-shrink: 0;
}

.history-session-info {
  flex: 1;
  min-width: 0;
}

.history-session-title {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-session-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
}

.history-session-actor {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
}
.history-session-actor svg { color: var(--muted); flex-shrink: 0; }

.history-session-stats {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.history-completeness-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  font-family: "Outfit", sans-serif;
  white-space: nowrap;
  border: 1px solid;
}

.history-stat {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.history-stat.ok {
  background: var(--ok-light);
  color: var(--ok);
}

.history-stat.warn {
  background: var(--warn-light);
  color: var(--warn);
}

.history-stat.error {
  background: var(--warn-light);
  color: var(--warn);
}

.history-delete-btn {
  display: grid;
  place-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 120ms ease, background 120ms ease, color 120ms ease;
  flex-shrink: 0;
}

.history-session-card:hover .history-delete-btn {
  opacity: 1;
}

.history-delete-btn:hover {
  background: var(--warn-light);
  color: var(--warn);
  border-color: #fecaca;
}

.history-session-bar {
  height: 4px;
  margin: 0 18px 10px;
  background: #ecedf2;
  border-radius: 999px;
  overflow: hidden;
}

.history-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 400ms ease;
}

.history-session-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 18px 14px;
}

.history-session-files {
  display: none;
  border-top: 1px solid var(--border);
}

.history-session-card.expanded .history-session-files {
  display: block;
}

/* ─── Responsive ─── */

@media (max-width: 1200px) {
  .fr-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .report-header {
    flex-wrap: wrap;
  }

  .report-header-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .history-session-header {
    flex-wrap: wrap;
  }

  .history-session-stats {
    width: 100%;
    flex-wrap: wrap;
  }

  .main-body {
    padding: 24px 20px;
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 260px;
    height: auto;
    position: static;
  }

  .sidebar-tree-panel {
    min-height: 0;
  }

  .main-body {
    padding: 20px 16px;
  }

  .bottom-row {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: 10px 16px;
  }

  .stats-row,
  .fr-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .fr-hero {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .fr-hero-meta {
    justify-content: center;
  }

  .fr-class-grid {
    grid-template-columns: 1fr;
  }

  .fr-health-checks {
    margin-left: 0;
  }

  .upload-page {
    padding: 20px 16px;
  }

  .drop-zone {
    padding: 32px 16px;
  }

  .upload-actions {
    flex-direction: column;
    gap: 8px;
  }

  .upload-action-btn {
    justify-content: center;
  }

  .report-verdict {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .verdict-score {
    margin: 0 auto;
  }

  .summary-table-wrap {
    overflow-x: auto;
  }

  .fr-download-section {
    flex-direction: column;
    text-align: center;
  }
}

/* ─── Sub-folder chip ─── */

.sub-folder-chip {
  background: #eff6ff !important;
  color: #2563eb !important;
  border: 1px solid #bfdbfe;
  font-weight: 500;
}

.sub-folder-label {
  font-size: 12px;
  color: #2563eb;
  background: #eff6ff;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.muted-text {
  color: var(--muted);
  font-size: 12px;
}

/* ─── Download Organized ZIP ─── */

.fr-download-section {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  margin-top: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.download-zip-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.download-zip-btn:hover {
  background: var(--accent-hover);
}

.download-zip-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.download-zip-hint {
  font-size: 13px;
  color: var(--muted);
}

/* ─── Info Tooltip Button ─── */

.info-tooltip-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 19px;
  height: 19px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--panel);
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  vertical-align: middle;
  margin-left: 4px;
  transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease, transform 80ms ease;
  position: relative;
  flex-shrink: 0;
}

.info-tooltip-btn:hover {
  background: #eef0ff;
  border-color: #c7d2fe;
  box-shadow: 0 1px 6px rgba(80, 70, 229, 0.15);
  transform: scale(1.1);
}

.info-tooltip-btn:active {
  transform: scale(0.95);
}

.info-tooltip-btn-inline {
  width: 16px;
  height: 16px;
  margin-left: 3px;
}

.info-tooltip-btn svg {
  display: block;
}

/* ─── Info Popover ─── */

.info-popover {
  position: absolute;
  z-index: 9999;
  max-width: 320px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  animation: popover-in 150ms ease;
}

.info-popover::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 12px;
  height: 12px;
  background: var(--panel);
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
}

@keyframes popover-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── Folder Structure Modal ─── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 46, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: modal-fade-in 160ms ease;
}

.modal-overlay.hidden {
  display: none;
}

@keyframes modal-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  animation: modal-slide-in 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes modal-slide-in {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-title {
  font-family: "Outfit", sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.modal-close-btn {
  display: grid;
  place-content: center;
  width: 30px;
  height: 30px;
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.modal-close-btn:hover {
  background: #f3f4f8;
  border-color: var(--border);
  color: var(--text);
}

.modal-body {
  overflow-y: auto;
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Sub-folder header row */
.fs-subfolder {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-top: 8px;
}

.fs-subfolder:first-child {
  margin-top: 0;
}

.fs-subfolder svg {
  color: var(--accent);
  flex-shrink: 0;
}

.fs-subfolder-name {
  flex: 1;
}

/* File rows inside the modal */
.fs-file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 120ms ease;
}

.fs-file-row:hover {
  background: #f3f4f8;
}

.fs-file-indented {
  padding-left: 28px;
}

.fs-file-icon {
  flex-shrink: 0;
  display: grid;
  place-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
}

.fs-file-icon.ok   { background: var(--ok-light); color: var(--ok); }
.fs-file-icon.warn { background: var(--warn-light); color: var(--warn); }
.fs-file-icon.info { background: #eef0ff; color: var(--accent); }
.fs-file-icon.error { background: var(--warn-light); color: var(--warn); }
.fs-file-icon.processing { background: #eef0ff; color: var(--accent); }

.fs-file-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.fs-file-meta {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ─── Checklist Table Accordion ─── */

/* Header row for an expandable item */
.checklist-row-found {
  cursor: pointer;
  user-select: none;
}

.checklist-row-found:hover td {
  background: #f7f7fb;
}

/* Chevron icon in the first cell */
.checklist-chevron {
  flex-shrink: 0;
  color: var(--muted);
  transition: transform 180ms ease;
  vertical-align: middle;
  margin-right: 6px;
  display: inline-block;
}

.checklist-row-found.expanded .checklist-chevron {
  transform: rotate(180deg);
}

/* Placeholder to keep alignment on NOT FOUND rows */
.checklist-chevron-placeholder {
  display: inline-block;
  width: 14px;
  margin-right: 6px;
}

/* The expand row that holds the file tree */
.checklist-expand-row td {
  padding: 0 !important;
  border-top: none !important;
  background: #fafafa;
}

.checklist-expand-row.hidden {
  display: none;
}

/* Wrapper inside the expand cell */
.checklist-tree {
  padding: 8px 16px 12px 24px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  border-bottom: 1px solid var(--border);
}

/* Sub-folder label row */
.cl-subfolder {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 8px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-top: 4px;
}

.cl-subfolder:first-child {
  margin-top: 0;
}

.cl-subfolder svg {
  color: var(--accent);
  flex-shrink: 0;
}

/* File row inside accordion */
.cl-file-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 110ms ease;
}

.cl-file-row:hover {
  background: #eef0ff;
}

.cl-file-indented {
  padding-left: 22px;
}

/* Icon badge */
.cl-file-icon {
  flex-shrink: 0;
  display: grid;
  place-content: center;
  width: 24px;
  height: 24px;
  border-radius: 5px;
}

.cl-file-icon.ok         { background: var(--ok-light);   color: var(--ok); }
.cl-file-icon.warn       { background: var(--warn-light);  color: var(--warn); }
.cl-file-icon.info       { background: #eef0ff;            color: var(--accent); }
.cl-file-icon.error      { background: var(--warn-light);  color: var(--warn); }
.cl-file-icon.processing { background: #eef0ff;            color: var(--accent); }

.cl-file-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cl-file-meta {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ─── Files by Status (collapsible groups on summary page) ─── */

.status-group {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  overflow: hidden;
  background: var(--panel);
}

.status-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  transition: background 120ms ease;
}

.status-group-header:hover {
  background: #f7f7fb;
}

.status-group-chevron {
  flex-shrink: 0;
  color: var(--muted);
  transition: transform 180ms ease;
}

.status-group.collapsed .status-group-chevron {
  transform: rotate(-90deg);
}

.status-group-dot {
  flex-shrink: 0;
  display: grid;
  place-content: center;
  width: 24px;
  height: 24px;
  border-radius: 5px;
}

.status-group-dot svg {
  width: 13px;
  height: 13px;
}

.status-group-label {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
}

.status-group-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  background: #f3f4f8;
  padding: 2px 8px;
  border-radius: 999px;
}

.status-group-body {
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 6px;
  background: #fafafa;
}

.status-group.collapsed .status-group-body {
  display: none;
}

.status-file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 110ms ease;
}

.status-file-row:hover {
  background: #eef0ff;
}

.status-file-cat {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 90px;
  text-align: center;
}

/* ─── Auth gate ─── */
.auth-gate {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.auth-gate.hidden { display: none; }
.auth-card {
  background: var(--panel);
  border-radius: 12px;
  padding: 48px 40px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  text-align: center;
  max-width: 400px;
  width: 90%;
}
.auth-card .brand {
  font-family: "Outfit", sans-serif;
  font-size: 28px;
  margin: 0 0 12px;
}
.auth-msg {
  color: var(--muted);
  margin: 0 0 24px;
  font-size: 14px;
}
.auth-button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 12px 32px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}
.auth-button:hover { background: var(--accent-hover); }
.auth-help {
  color: var(--muted);
  font-size: 12px;
  margin: 24px 0 0;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 24px 0 0;
}
.login-input {
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}
.login-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(80, 70, 229, 0.12);
}
.auth-error {
  color: #dc2626;
  font-size: 13px;
  margin: 0;
  text-align: left;
}
.auth-error.hidden { display: none; }

.auth-success {
  color: #047857;
  font-size: 13px;
  margin: 0;
  text-align: left;
}
.auth-success.hidden { display: none; }

/* "Forgot password?", "Resend code", "Cancel sign-in" — secondary text actions
   inside auth/MFA forms. Render like a link, not a button. */
.auth-link {
  background: none;
  border: none;
  padding: 4px;
  margin: 4px auto 0;
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
}
.auth-link:hover { color: var(--accent-hover); }

/* 6-digit OTP input — wider letter spacing so digits are easy to read. */
.mfa-code-input {
  text-align: center;
  letter-spacing: 0.5em;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* Hint text under MFA / change-password fields */
.field-hint {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

/* Change-password collapsible section in the profile editor */
.profile-changepw {
  margin-top: 18px;
  border-top: 1px solid #e5e7eb;
  padding-top: 16px;
}
.profile-changepw.hidden { display: none; }
.profile-changepw > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  list-style: none;
  padding: 4px 0;
}
.profile-changepw > summary::-webkit-details-marker { display: none; }
.profile-changepw > summary::before {
  content: "▸ ";
  display: inline-block;
  margin-right: 4px;
  transition: transform 0.15s;
}
.profile-changepw[open] > summary::before {
  content: "▾ ";
}
.profile-changepw > .profile-form {
  margin-top: 12px;
}

/* invite-status colour variants used by change-password / MFA enrollment */
.invite-status.success { color: #047857; }
.invite-status.error { color: #dc2626; }

/* ─── User bar (sits inside .topbar on the right): avatar trigger + dropdown ─── */
.user-bar {
  position: relative;        /* anchor for the absolute-positioned dropdown */
}
.user-bar.hidden { display: none; }

.user-menu-trigger {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: box-shadow 0.15s, transform 0.1s;
  font-family: inherit;
}
.user-menu-trigger:hover { box-shadow: 0 4px 12px rgba(80, 70, 229, 0.22); }
.user-menu-trigger:active { transform: scale(0.96); }
.user-menu-trigger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.user-avatar {
  font-family: "Outfit", sans-serif;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  line-height: 1;
}

.user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  background: var(--panel);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  padding: 6px 0;
  border: 1px solid #e5e7eb;
  animation: userMenuIn 0.12s ease-out;
  z-index: 100;
}
.user-menu.hidden { display: none; }
@keyframes userMenuIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.user-menu-header {
  padding: 10px 14px 8px;
}
.user-menu-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-menu-email {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-menu-divider {
  height: 1px;
  background: #e5e7eb;
  margin: 4px 0;
}

.user-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: transparent;
  border: none;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}
.user-menu-item:hover { background: var(--bg); }
.user-menu-item:focus-visible {
  outline: none;
  background: var(--bg);
}
.user-menu-item.hidden { display: none; }
.user-menu-item svg { color: var(--muted); flex-shrink: 0; }
.user-menu-item:hover svg { color: var(--text); }
.user-menu-danger { color: #dc2626; }
.user-menu-danger:hover { background: #fee2e2; }
.user-menu-danger svg { color: #dc2626; }
.user-menu-danger:hover svg { color: #dc2626; }

/* ─── Profile setup / editor ─── */
.profile-card { max-width: 460px; padding: 36px 32px; }
.profile-title {
  margin: 16px 0 4px;
  font-family: "Outfit", sans-serif;
  font-size: 20px;
  font-weight: 600;
}
.profile-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 20px;
  text-align: left;
}
.profile-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
}
.profile-form label > span {
  font-weight: 500;
}
.profile-form em.req { color: #dc2626; font-style: normal; }
.profile-form em.opt { color: var(--muted); font-style: normal; font-weight: 400; }
.profile-form input[type="text"],
.profile-form input[type="tel"] {
  padding: 9px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}
.profile-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(80, 70, 229, 0.12);
}
.profile-terms {
  flex-direction: row !important;
  align-items: flex-start;
  gap: 10px !important;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}
.profile-terms input[type="checkbox"] { margin-top: 2px; flex-shrink: 0; }
.profile-terms a { color: var(--accent); }
.profile-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 8px;
}
.profile-actions .ghost-btn {
  background: transparent;
  border: 1px solid var(--muted);
  color: var(--muted);
  padding: 9px 18px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
}
.profile-actions .ghost-btn.hidden { display: none; }
#profileSubmit {
  background: var(--accent);
  color: white;
  border: none;
  padding: 9px 22px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}
#profileSubmit:hover { background: var(--accent-hover); }
#profileSubmit:disabled { opacity: 0.6; cursor: not-allowed; }

/* ─── Invite form layout ─── */
.invite-form { flex-direction: column; }
.invite-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.invite-row input { flex: 1; min-width: 0; }
.invite-submit-row { justify-content: flex-end; margin-bottom: 0; }
.invite-submit-row button { flex: 0 0 auto; }
.users-table input.designation-input {
  padding: 4px 8px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 12px;
  font-family: inherit;
  width: 100%;
  max-width: 180px;
}

/* ─── Admin: user management modal ─── */
.admin-panel { max-width: 720px; width: 90vw; }
.invite-form {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--bg);
  border-radius: 8px;
}
.invite-form input,
.invite-form select {
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: var(--panel);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.invite-form input:focus,
.invite-form select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(80, 70, 229, 0.12);
}
/* Strip native <select> chrome and add a custom caret, matching the rest of the
   site. Needs appearance:none on all engines + a background-image arrow.
   Without this, browsers paint their own dropdown widget that ignores our
   border / focus treatment. */
.invite-form select,
.users-table select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a8fa8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  cursor: pointer;
}
.invite-form select::-ms-expand,
.users-table select::-ms-expand { display: none; }

/* ─── Custom select component (replaces native <select> popup, which is
   an OS-rendered widget that can't be CSS-styled) ─── */
.custom-select {
  position: relative;
  display: inline-block;
  font-family: inherit;
}
.custom-select.full { display: block; }
.custom-select select.native-select {
  /* The hidden native <select> stays in the DOM for form semantics —
     existing JS that reads .value or attaches change listeners keeps working. */
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.custom-select-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: var(--panel);
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.custom-select-trigger:hover { border-color: #9ca3af; }
.custom-select-trigger:focus,
.custom-select.open .custom-select-trigger {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(80, 70, 229, 0.12);
}
.custom-select-caret {
  margin-left: 10px;
  flex-shrink: 0;
  color: var(--muted);
  transition: transform 0.15s;
}
.custom-select.open .custom-select-caret { transform: rotate(180deg); }

.custom-select-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--panel);
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10);
  padding: 4px;
  z-index: 50;
  list-style: none;
  margin: 0;
  animation: customSelectIn 0.1s ease-out;
}
.custom-select:not(.open) .custom-select-menu { display: none; }
@keyframes customSelectIn {
  from { opacity: 0; transform: translateY(-2px); }
  to   { opacity: 1; transform: translateY(0); }
}
.custom-select-option {
  padding: 7px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  user-select: none;
}
.custom-select-option:hover { background: var(--bg); }
.custom-select-option.selected {
  background: rgba(80, 70, 229, 0.08);
  color: var(--accent);
  font-weight: 500;
}

/* Compact variant for inline use inside the users table */
.custom-select.compact .custom-select-trigger {
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 4px;
}
.custom-select.compact .custom-select-option {
  padding: 5px 8px;
  font-size: 12px;
}
.custom-select.compact .custom-select-caret { width: 10px; height: 10px; }
.invite-form input { flex: 1; }
.invite-form button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
}
.invite-form button:hover { background: var(--accent-hover); }
.invite-form button:disabled { opacity: 0.6; cursor: not-allowed; }
.invite-status {
  font-size: 13px;
  margin-bottom: 12px;
  min-height: 20px;
}
.invite-status.success { color: var(--ok); }
.invite-status.error { color: #dc2626; }
.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.users-table th,
.users-table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid #e5e7eb;
}
.users-table th { font-weight: 600; color: var(--muted); }
.users-table tbody tr:hover { background: var(--bg); }
.users-table select {
  padding: 4px 24px 4px 8px;       /* extra right padding for the caret */
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 12px;
  font-family: inherit;
  color: var(--text);
  background-color: var(--panel);
  background-position: right 6px center;
  background-size: 10px 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.users-table select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(80, 70, 229, 0.12);
}
.users-table .delete-btn {
  background: transparent;
  color: #dc2626;
  border: 1px solid #dc2626;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}
.users-table .delete-btn:hover { background: #dc2626; color: white; }
.users-table .self-tag {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
}
