/* ============================================
   AICE Documents — Design System
   ============================================ */

:root {
  /* Brand */
  --brand-blue: #2563eb;
  --brand-blue-dark: #1d4ed8;
  --brand-blue-light: #eff6ff;

  /* Text */
  --text-primary: #111827;
  --text-secondary: #374151;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;

  /* Surfaces */
  --bg-white: #ffffff;
  --bg-gray: #f9fafb;
  --bg-sidebar: #ffffff;
  --border-color: #e5e7eb;
  --border-color-strong: #d1d5db;

  /* Status */
  --success: #10b981;
  --success-bg: #d1fae5;
  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --danger: #ef4444;
  --danger-bg: #fee2e2;
  --purple: #8b5cf6;
  --purple-bg: #ede9fe;

  /* Tag colors */
  --tag-blue-bg: #dbeafe;   --tag-blue-text: #1d4ed8;
  --tag-green-bg: #d1fae5;  --tag-green-text: #047857;
  --tag-purple-bg: #ede9fe; --tag-purple-text: #6d28d9;
  --tag-orange-bg: #ffedd5; --tag-orange-text: #c2410c;

  /* Radius / shadow */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);

  --sidebar-width: 260px;
  --preview-width: clamp(480px, 50vw, 900px);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--aice-font, 'AICE Light'), 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text-primary);
  background: var(--bg-gray);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

/* ===== App shell ===== */
.app-container { display: flex; min-height: calc(100vh / var(--zv, 1)); }

.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.content-area { padding: 24px 32px; flex: 1; }

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px 20px;
}

.brand-logo {
  font-size: 18px;
  font-weight: 800;
  color: var(--brand-blue);
  letter-spacing: -0.02em;
}
.brand-logo span { color: var(--text-primary); font-weight: 700; }

.upload-btn-sidebar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--brand-blue);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 16px;
  transition: background 0.15s;
}
.upload-btn-sidebar:hover { background: var(--brand-blue-dark); }

.sidebar-nav { flex: 1; }

.nav-section { margin-bottom: 20px; }

.nav-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  padding: 0 12px 6px;
}
.nav-section-toggle {
  display: flex; align-items: center; gap: 6px; width: 100%; background: none; border: none;
  cursor: pointer; text-align: left; padding: 0 12px 6px; margin: 0; appearance: none;
  outline: none; font: inherit; -webkit-tap-highlight-color: transparent;
}
.nav-section-toggle svg { transition: transform 0.15s; }
.nav-section-toggle:hover { color: var(--text-secondary); }
.nav-section-toggle:focus, .nav-section-toggle:focus-visible, .nav-section-toggle:active { outline: none; box-shadow: none; background: none; }

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 14px;
  margin-bottom: 2px;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--bg-gray); color: var(--text-primary); }
.nav-item-label { display: flex; align-items: center; gap: 10px; }
.nav-item.active { background: var(--brand-blue-light); color: var(--brand-blue); font-weight: 600; }

.nav-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-gray);
  padding: 1px 7px;
  border-radius: 10px;
}
.nav-item.active .nav-badge { background: #dbeafe; color: var(--brand-blue); }

.folder-tree { display: flex; flex-direction: column; }

.folder-item {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 2px;
}
.folder-item:hover { background: var(--bg-gray); }
.folder-item.active { background: var(--brand-blue-light); color: var(--brand-blue); font-weight: 600; }

.sidebar-footer {
  border-top: 1px solid var(--border-color);
  padding-top: 14px;
  margin-top: 8px;
}

.storage-bar {
  height: 6px;
  background: var(--bg-gray);
  border-radius: 3px;
  margin-top: 8px;
  overflow: hidden;
}
.storage-fill {
  height: 100%;
  width: 17%;
  background: var(--brand-blue);
  border-radius: 3px;
}

/* ===== Top header ===== */
.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 32px;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 30;
}

.search-box {
  position: relative;
  flex: 1;
  max-width: 520px;
}
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
}
.search-box input {
  width: 100%;
  padding: 10px 12px 10px 38px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-gray);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.search-box input:focus {
  background: var(--bg-white);
  border-color: var(--brand-blue);
}

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

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  transition: background 0.12s;
}
.icon-btn:hover { background: var(--bg-gray); }

.notification-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--bg-white);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 4px 4px;
  border-radius: var(--radius-md);
  cursor: pointer;
}
.user-profile:hover { background: var(--bg-gray); }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }
.user-name { font-size: 13px; font-weight: 600; line-height: 1.3; }
.user-dept { font-size: 12px; color: var(--text-muted); line-height: 1.3; }

/* ===== Breadcrumb / page header ===== */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--brand-blue); }

.page-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.page-subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }

/* ===== Toolbar ===== */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border: 1px solid var(--border-color-strong);
  background: var(--bg-white);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--bg-gray); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-ghost { border-color: transparent; }
.btn-ghost:hover { background: var(--bg-gray); }

.btn-primary {
  background: var(--brand-blue);
  border-color: var(--brand-blue);
  color: #fff;
}
.btn-primary:hover { background: var(--brand-blue-dark); }

.view-toggle {
  display: flex;
  border: 1px solid var(--border-color-strong);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.view-toggle button {
  border: none;
  background: var(--bg-white);
  padding: 8px 10px;
  color: var(--text-muted);
  border-right: 1px solid var(--border-color);
}
.view-toggle button:last-child { border-right: none; }
.view-toggle button.active { background: var(--brand-blue-light); color: var(--brand-blue); }

/* ===== Document table ===== */
.doc-table-container {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.doc-table { width: 100%; border-collapse: collapse; }

.doc-table thead th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-gray);
}

.doc-table tbody tr {
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background 0.1s;
}
.doc-table tbody tr:hover { background: var(--bg-gray); }
.doc-table tbody tr.selected { background: var(--brand-blue-light); }
.doc-table tbody tr:last-child { border-bottom: none; }

.doc-table td { padding: 12px 16px; vertical-align: middle; font-size: 13px; color: var(--text-secondary); }

.doc-checkbox { width: 16px; height: 16px; accent-color: var(--brand-blue); cursor: pointer; }

.doc-name-cell { display: flex; align-items: center; gap: 12px; }

.file-icon {
  width: 34px;
  height: 38px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}
.file-icon.pdf { background: #ef4444; }
.file-icon.docx { background: #2563eb; }
.file-icon.xlsx { background: #10b981; }
.file-icon.image { background: #8b5cf6; }
.file-icon.default { background: #6b7280; }

.doc-title { font-weight: 600; color: var(--text-primary); font-size: 13px; }

.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  margin-right: 4px;
}
.tag-blue { background: var(--tag-blue-bg); color: var(--tag-blue-text); }
.tag-green { background: var(--tag-green-bg); color: var(--tag-green-text); }
.tag-purple { background: var(--tag-purple-bg); color: var(--tag-purple-text); }
.tag-orange { background: var(--tag-orange-bg); color: var(--tag-orange-text); }

.correspondent-label { font-weight: 700; }
.correspondent-label.correspondent-blue { color: var(--tag-blue-text); }
.correspondent-label.correspondent-green { color: var(--tag-green-text); }
.correspondent-label.correspondent-purple { color: var(--tag-purple-text); }
.correspondent-label.correspondent-orange { color: var(--tag-orange-text); }

.uploader-cell { display: flex; align-items: center; gap: 8px; }
.uploader-avatar { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }

.date-cell { color: var(--text-muted); line-height: 1.4; }
.size-cell { color: var(--text-muted); }

.row-actions { display: flex; justify-content: flex-end; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}
.status-badge.warning { background: var(--warning-bg); color: #b45309; }
.status-badge.success { background: var(--success-bg); color: #047857; }
.status-badge.purple { background: var(--purple-bg); color: #6d28d9; }
.status-badge.danger { background: var(--danger-bg); color: #b91c1c; }

/* ===== Pagination ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-top: 1px solid var(--border-color);
  font-size: 13px;
  color: var(--text-muted);
}
.pagination-buttons { display: flex; gap: 4px; }
.pagination-buttons button {
  min-width: 32px;
  height: 32px;
  border: 1px solid var(--border-color);
  background: var(--bg-white);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
}
.pagination-buttons button:hover { background: var(--bg-gray); }
.pagination-buttons button.active { background: var(--brand-blue); border-color: var(--brand-blue); color: #fff; }

/* ===== Preview panel ===== */
.preview-panel {
  width: 0;
  overflow: hidden;
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  flex-shrink: 0;
  transition: width 0.2s ease;
  display: flex;
  flex-direction: column;
}
.preview-panel.open { width: var(--preview-width); margin-left: 20px; }

.preview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px;
  border-bottom: 1px solid var(--border-color);
}
.preview-title { font-weight: 600; font-size: 14px; word-break: break-word; }
.preview-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.preview-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  padding: 0 18px;
  overflow-x: auto;
}
.preview-tab {
  padding: 12px 4px;
  margin-right: 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}
.preview-tab:hover { color: var(--text-primary); }
.preview-tab.active { color: var(--brand-blue); border-bottom-color: var(--brand-blue); }

.preview-content { padding: 18px; overflow-y: auto; flex: 1; }

.pdf-viewer {
  background: #1f2937;
  color: #9ca3af;
  border-radius: var(--radius-md);
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
}

.ai-tags-section { margin-bottom: 18px; }
.ai-tags-title { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 10px; }

.info-row {
  display: flex;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 13px;
}
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--text-muted); }
.info-value { color: var(--text-primary); font-weight: 500; }

.workflow-step { display: flex; gap: 12px; padding-bottom: 20px; position: relative; }
.workflow-step:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 13px; top: 28px; bottom: 0;
  width: 2px;
  background: var(--border-color);
}
.step-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  z-index: 1;
}
.step-dot.completed { background: var(--success); color: #fff; }
.step-dot.pending { background: var(--bg-gray); color: var(--text-faint); border: 2px solid var(--border-color); }
.step-dot.current { background: var(--brand-blue); color: #fff; }
.step-name { font-weight: 600; font-size: 13px; }
.step-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ===== Workflow templates page ===== */
.workflow-layout { display: grid; grid-template-columns: 280px 1fr; gap: 20px; align-items: start; }

.workflow-template-list { background: var(--bg-white); border: 1px solid var(--border-color); border-radius: var(--radius-lg); overflow: hidden; }
.workflow-template-item {
  display: block; padding: 14px 16px; border-bottom: 1px solid var(--border-color);
  color: var(--text-primary); text-decoration: none;
}
.workflow-template-item:last-child { border-bottom: none; }
.workflow-template-item:hover { background: var(--bg-gray); }
.workflow-template-item.active { background: var(--brand-blue-light); }
.workflow-template-item.active .wt-name { color: var(--brand-blue); }
.wt-name { font-weight: 700; font-size: 13px; }
.wt-count { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* Horizontal pipeline (overview of a template's steps) */
.pipeline { display: flex; align-items: flex-start; }
.pipeline-node { display: flex; flex-direction: column; align-items: center; flex: 1; text-align: center; }
.pipeline-node .step-dot { width: 34px; height: 34px; }
.pipeline-node .pipeline-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-top: 8px; max-width: 100px; }
.pipeline-connector { height: 2px; background: var(--border-color); flex: 1; margin-top: 17px; }

/* Per-document progress bar inside the instance list */
.wf-progress-track { display: flex; gap: 4px; }
.wf-progress-seg { height: 6px; flex: 1; border-radius: 3px; background: var(--border-color); }
.wf-progress-seg.done { background: var(--success); }
.wf-progress-seg.current { background: var(--brand-blue); }

.wf-instance-row {
  display: flex; align-items: center; gap: 16px; padding: 14px 16px; border-bottom: 1px solid var(--border-color);
}
.wf-instance-row:last-child { border-bottom: none; }
.wf-instance-doc { width: 220px; flex-shrink: 0; min-width: 0; }
.wf-instance-doc .doc-name-cell { gap: 10px; }
.wf-instance-doc .doc-title { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wf-instance-owner { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.wf-instance-progress { flex: 1; min-width: 0; }
.wf-instance-stage { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.wf-actions { display: flex; gap: 8px; flex-shrink: 0; }
.btn-approve { background: var(--success); border-color: var(--success); color: #fff; }
.btn-approve:hover { background: #0ea975; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-reject { background: #fff; border-color: var(--danger); color: var(--danger); }
.btn-reject:hover { background: var(--danger-bg); }

/* ===== Dashboard: OCR queue / favorites / insights widgets ===== */
.ocr-queue-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 13px; }
.ocr-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.ocr-dot.completed { background: var(--success); }
.ocr-dot.processing { background: var(--brand-blue); }
.ocr-dot.pending { background: var(--warning); }
.ocr-dot.failed { background: var(--danger); }
.ocr-queue-label { flex: 1; color: var(--text-secondary); }
.ocr-queue-count { font-weight: 700; }

.favorite-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 13px; color: var(--text-secondary); }
.favorite-row svg { flex-shrink: 0; }
.favorite-row span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.insight-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px; background: var(--purple-bg); border-radius: var(--radius-md); font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; }
.insight-row:last-child { margin-bottom: 0; }
.insight-row svg { flex-shrink: 0; margin-top: 1px; color: var(--purple); }

/* ===== New Folder modal: color swatch picker ===== */
.color-swatch-picker { display: flex; flex-wrap: wrap; gap: 10px; }
.color-swatch {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent;
  cursor: pointer; padding: 0; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
}
.color-swatch:hover { transform: scale(1.1); }
.color-swatch.selected { border-color: var(--text-primary); box-shadow: 0 0 0 2px var(--bg-white), 0 0 0 4px var(--text-primary); }

/* ===== Sidebar folder delete button ===== */
.folder-delete-btn {
  opacity: 0; background: none; border: none; cursor: pointer; padding: 2px;
  border-radius: var(--radius-sm); color: var(--text-faint); display: flex; align-items: center;
  margin-left: auto; flex-shrink: 0;
}
.nav-item:hover .folder-delete-btn { opacity: 1; }
.folder-row:hover .folder-delete-btn { opacity: 1; }
.folder-delete-btn:hover { background: var(--danger-bg); color: var(--danger); }

/* ===== Row "..." dropdown menu ===== */
.row-menu-dropdown {
  position: absolute; z-index: 120; background: var(--bg-white); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg); padding: 6px; min-width: 190px;
}
.row-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 8px 10px; border: none; background: none; border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-primary); cursor: pointer;
}
.row-menu-item:hover { background: var(--bg-gray); }
.row-menu-item.danger { color: var(--danger); }
.row-menu-item.danger:hover { background: var(--danger-bg); }

.tag-removable { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; border: none; }
.tag-removable:hover { opacity: 0.75; }

/* ===== docx / xlsx inline preview ===== */
.docx-preview {
  background: #fff; padding: 32px; border-radius: var(--radius-md); border: 1px solid var(--border-color);
  max-height: 70vh; overflow-y: auto; font-size: 14px; line-height: 1.6; color: var(--text-primary);
}
.docx-preview p { margin: 0 0 12px; }
.docx-preview table { border-collapse: collapse; margin-bottom: 12px; }
.docx-preview table td, .docx-preview table th { border: 1px solid var(--border-color); padding: 6px 10px; }

.xlsx-preview {
  background: #fff; border-radius: var(--radius-md); border: 1px solid var(--border-color);
  max-height: 65vh; overflow: auto;
}
.xlsx-preview table { border-collapse: collapse; font-size: 12px; width: 100%; }
.xlsx-preview table td, .xlsx-preview table th {
  border: 1px solid var(--border-color); padding: 5px 9px; white-space: nowrap;
}
.xlsx-preview table tr:first-child { background: var(--bg-gray); font-weight: 600; }

/* ===== Live search suggestions dropdown ===== */
.search-suggestions {
  display: none; position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--bg-white); border: 1px solid var(--border-color); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); z-index: 150; max-height: 360px; overflow-y: auto;
}
.search-suggestions.open { display: block; }
.search-suggestion-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 14px; text-decoration: none;
  color: var(--text-primary); font-size: 13px; border-bottom: 1px solid var(--border-color);
}
.search-suggestion-item:last-child { border-bottom: none; }
.search-suggestion-item:hover { background: var(--bg-gray); }
.search-suggestion-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-suggestion-all { color: var(--brand-blue); font-weight: 600; justify-content: center; }

/* ===== Grid view ===== */
.doc-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; padding: 4px 0;
}
.doc-card {
  background: var(--bg-white); border: 1px solid var(--border-color); border-radius: var(--radius-lg);
  padding: 16px; cursor: pointer; transition: box-shadow 0.12s, border-color 0.12s;
}
.doc-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-color-strong); }
.doc-card-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 10px; }
.doc-card-name {
  font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 6px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.35;
}
.doc-card-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.doc-card-tags { display: flex; flex-wrap: wrap; gap: 4px; }

.row-menu-item.active-sort { background: var(--brand-blue-light); color: var(--brand-blue); font-weight: 600; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(17,24,39,0.5);
  display: none;
  align-items: center; justify-content: center;
  z-index: 100;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  width: 420px;
  max-width: 92vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; padding: 20px; border-bottom: 1px solid var(--border-color); }
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { border: none; background: transparent; color: var(--text-muted); padding: 4px; border-radius: 6px; }
.modal-close:hover { background: var(--bg-gray); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 20px; border-top: 1px solid var(--border-color); }

.folder-tree-modal .folder-node {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-secondary);
}
.folder-tree-modal .folder-node:hover { background: var(--bg-gray); }
.folder-tree-modal .folder-node.selected { background: var(--brand-blue-light); color: var(--brand-blue); font-weight: 600; }
.folder-tree-modal .folder-children { padding-left: 16px; }

/* ===== Toasts ===== */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 200;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  transition: opacity 0.3s, transform 0.3s;
}

/* ===== Split-view page cards ===== */
.page-card {
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  background: var(--bg-white);
  position: relative;
  transition: border-color 0.12s;
}
.page-card:hover { border-color: var(--border-color-strong); }
.page-card.selected { border-color: var(--brand-blue); }
.page-card.dragging { opacity: 0.5; }
.page-number {
  position: absolute; top: 6px; left: 6px;
  width: 22px; height: 22px;
  background: rgba(17,24,39,0.7);
  color: #fff;
  border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
}
.page-card input[type="checkbox"] {
  position: absolute; bottom: 8px; left: 8px;
  width: 16px; height: 16px;
  accent-color: var(--brand-blue);
}
.page-thumb {
  height: 130px;
  background: var(--bg-gray);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}
.page-card-label {
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-color);
}

.group-box {
  border: 2px dashed var(--border-color-strong);
  border-radius: var(--radius-md);
  padding: 14px;
  min-height: 160px;
  background: var(--bg-gray);
}
.group-box.filled { border-style: solid; background: var(--bg-white); }
.group-box.drag-over { border-color: var(--brand-blue); background: var(--brand-blue-light); }
.group-box.active-group { border-color: var(--brand-blue); box-shadow: 0 0 0 2px var(--brand-blue-light); }
.page-blank-badge {
  position: absolute; top: 4px; right: 4px; font-size: 9px; font-weight: 700; text-transform: uppercase;
  background: var(--warning); color: #fff; padding: 1px 5px; border-radius: 4px;
}
.page-rotate-btn {
  position: absolute; bottom: 4px; right: 4px; z-index: 2; width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center; border-radius: 50%;
  background: rgba(17,24,39,0.65); color: #fff; border: none; cursor: pointer;
}
.page-rotate-btn:hover { background: rgba(17,24,39,0.85); }
.group-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.group-pages { display: flex; flex-wrap: wrap; gap: 6px; min-height: 26px; }
.group-page-chip {
  background: var(--brand-blue-light);
  color: var(--brand-blue);
  font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 10px;
}
.add-group-btn {
  border: 2px dashed var(--border-color-strong);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  min-height: 160px;
  color: var(--text-faint);
  cursor: pointer;
  background: transparent;
}
.add-group-btn:hover { border-color: var(--brand-blue); color: var(--brand-blue); }

.split-option-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  background: var(--bg-white);
}
.split-option-card h4 { margin: 0 0 4px; font-size: 13px; font-weight: 700; }
.split-option-card p { margin: 0; font-size: 12px; color: var(--text-muted); }

.field-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 8px;
}
.field-select {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: var(--bg-gray);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; font-size: 13px; color: var(--text-secondary); }
.toggle-switch {
  width: 36px; height: 20px;
  background: var(--border-color-strong);
  border-radius: 10px;
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
}
.toggle-switch.on { background: var(--brand-blue); }
.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: left 0.15s;
}
.toggle-switch.on::after { left: 18px; }

/* ===== Dashboard ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px;
}
.stat-card-label { font-size: 12px; color: var(--text-muted); font-weight: 600; margin-bottom: 6px; }
.stat-card-value { font-size: 26px; font-weight: 800; color: var(--text-primary); }
.stat-card-sub { font-size: 12px; color: var(--success); margin-top: 4px; font-weight: 600; }

.dashboard-grid { display: grid; grid-template-columns: 1fr 380px; gap: 20px; }

.panel {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px;
}
.panel-title { font-size: 15px; font-weight: 700; margin-bottom: 14px; }

.quick-access-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.quick-access-card {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.12s;
}
.quick-access-card:hover { border-color: var(--brand-blue); }
.quick-access-card .qa-count { font-size: 20px; font-weight: 800; margin-top: 8px; }
.quick-access-card .qa-label { font-size: 12px; color: var(--text-muted); font-weight: 600; }

/* ===== Utility / fade ===== */
.fade-in { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Responsive ===== */
@media (max-width: 1100px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .quick-access-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.2s; z-index: 50; }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .preview-panel.open { position: fixed; right: 0; top: 0; bottom: 0; z-index: 60; margin-left: 0; border-radius: 0; }
}

/* Keyboard focus visibility */
a:focus-visible, button:focus-visible, input:focus-visible, .nav-item:focus-visible {
  outline: 2px solid var(--brand-blue);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
