/* ══════════════════════════════════════════════════════════
   DocuVault — CSS Principal
   Design: painel profissional arquival, neutro mas refinado
   ══════════════════════════════════════════════════════════ */

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

:root {
  /* Paleta Light */
  --c-bg:        #f4f4f7;
  --c-surface:   #ffffff;
  --c-surface2:  #f0f0f5;
  --c-border:    #e2e2ea;
  --c-text:      #18181b;
  --c-muted:     #71717a;
  --c-accent:    #4f46e5;
  --c-accent2:   #7c3aed;
  --c-success:   #16a34a;
  --c-warning:   #d97706;
  --c-danger:    #dc2626;
  --c-info:      #0284c7;

  /* Sidebar */
  --sb-bg:       #1e1b4b;
  --sb-text:     #c7d2fe;
  --sb-muted:    #818cf8;
  --sb-active:   #4f46e5;
  --sb-hover:    rgba(99,102,241,.15);
  --sb-width:    240px;

  /* Topbar */
  --tb-h:        52px;

  /* Misc */
  --radius:      8px;
  --radius-lg:   12px;
  --shadow:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg:   0 10px 25px rgba(0,0,0,.12);
  --transition:  .15s ease;
  --font:        'Inter', system-ui, sans-serif;
  --font-mono:   'JetBrains Mono', monospace;
}

[data-theme="dark"] {
  --c-bg:        #09090b;
  --c-surface:   #18181b;
  --c-surface2:  #27272a;
  --c-border:    #3f3f46;
  --c-text:      #fafafa;
  --c-muted:     #a1a1aa;
  --c-accent:    #818cf8;
  --sb-bg:       #09090b;
  --sb-border:   #27272a;
}

html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  min-width: 0;
}
a { color: var(--c-accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ── Anti-Screenshot Shield ───────────────────────────────── */
#ss-shield {
  position: fixed; inset: 0; z-index: 99999;
  background: rgba(15,15,20,.97);
  backdrop-filter: blur(20px) saturate(0);
  display: none;
  align-items: center; justify-content: center;
  flex-direction: column;
  color: #fff;
}
#ss-shield.active { display: flex; }
.ss-shield-inner {
  text-align: center;
}
.ss-shield-inner svg {
  width: 64px; height: 64px;
  stroke: #818cf8; margin-bottom: 16px;
}
.ss-shield-inner p {
  font-size: 1.1rem; opacity: .7; letter-spacing: .03em;
}

/* ── Layout ───────────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sb-width);
  background: var(--sb-bg);
  display: flex; flex-direction: column;
  z-index: 100;
  transition: transform var(--transition), width var(--transition);
  overflow: hidden;
}
.sidebar.collapsed { width: 60px; }
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .sidebar-search,
.sidebar.collapsed .user-info,
.sidebar.collapsed .nav-divider span { display: none; }
.sidebar.collapsed .nav-divider { border-top: 1px solid rgba(255,255,255,.08); margin: 6px 0; }

.main-wrapper {
  margin-left: var(--sb-width);
  min-height: 100vh;
  min-width: 0;
  max-width: calc(100vw - var(--sb-width));
  display: flex; flex-direction: column;
  transition: margin-left var(--transition);
  overflow-x: hidden;
}
.main-wrapper.expanded {
  margin-left: 60px;
  max-width: calc(100vw - 60px);
}

/* ── Sidebar Header ───────────────────────────────────────── */
.sidebar-header {
  display: flex; align-items: center;
  padding: 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  color: #fff; text-decoration: none; flex: 1;
  font-weight: 700; font-size: .95rem; letter-spacing: .02em;
}
.logo-icon {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0;
}
.sidebar-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--sb-muted); padding: 4px; border-radius: 4px;
}
.sidebar-toggle svg { width: 18px; height: 18px; display: block; }
.sidebar-toggle:hover { color: #fff; background: var(--sb-hover); }

/* ── Sidebar Search ───────────────────────────────────────── */
.sidebar-search { padding: 10px 10px 6px; }
.search-wrap {
  position: relative; display: flex; align-items: center;
}
.search-icon {
  position: absolute; left: 8px; width: 14px; height: 14px;
  color: var(--sb-muted); pointer-events: none;
}
.sidebar-search input {
  width: 100%; background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 6px; color: #fff;
  font-size: .8rem; padding: 6px 8px 6px 28px;
  outline: none; transition: border-color var(--transition);
}
.sidebar-search input::placeholder { color: var(--sb-muted); }
.sidebar-search input:focus { border-color: var(--sb-active); }

/* ── Sidebar Nav ──────────────────────────────────────────── */
.sidebar-nav {
  list-style: none; padding: 6px 8px; flex: 1; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.1) transparent;
}
.sidebar-nav .nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 6px;
  color: var(--sb-text); font-size: .84rem; font-weight: 500;
  transition: background var(--transition), color var(--transition);
  text-decoration: none; white-space: nowrap;
}
.sidebar-nav .nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-nav .nav-item:hover { background: var(--sb-hover); color: #fff; }
.sidebar-nav .nav-item.active { background: var(--sb-active); color: #fff; }
.nav-divider {
  padding: 14px 10px 4px;
  font-size: .7rem; letter-spacing: .06em;
  text-transform: uppercase; color: var(--sb-muted); font-weight: 600;
}

/* ── Sidebar Footer ───────────────────────────────────────── */
/* ── Sidebar Stats ──────────────────────────────────────────── */
.sidebar-stats {
  margin: 4px 8px 8px; padding: 10px 12px;
  background: rgba(255,255,255,.05); border-radius: 8px;
  cursor: pointer; transition: background var(--transition); font-size:.72rem;
}
.sidebar-stats:hover { background: rgba(255,255,255,.09); }
.sidebar.collapsed .sidebar-stats { display: none; }
.ss-row { display:flex; justify-content:space-between; align-items:center; }
.ss-label { color: var(--sb-muted); font-size:.7rem; }
.ss-val   { color: rgba(255,255,255,.7); font-size:.7rem; font-weight:500; }
.ss-bar-wrap { height:4px; background:rgba(255,255,255,.1); border-radius:2px; margin-top:3px; overflow:hidden; }
.ss-bar { height:100%; border-radius:2px; background:var(--c-accent); transition:width .6s ease; }
.ss-bar-green { background: var(--c-success); }
.ss-types { margin-top:8px; display:flex; flex-direction:column; gap:3px; }
.ss-type-row { display:flex; align-items:center; gap:4px; }
.ss-type-label { color:var(--sb-muted); width:28px; flex-shrink:0; font-size:.65rem; }
.ss-type-bar-wrap { flex:1; height:3px; background:rgba(255,255,255,.1); border-radius:2px; overflow:hidden; }
.ss-type-bar { height:100%; background:#818cf8; border-radius:2px; transition:width .5s ease; }
.ss-type-cnt { color:rgba(255,255,255,.4); width:20px; text-align:right; font-size:.65rem; }
.ss-chart-wrap { margin-top:8px; }
.ss-chart-wrap canvas { width:100%; display:block; }
/* Badge cadeado nos cards de arquivo */
.file-thumb .file-lock-badge {
  position:absolute; bottom:6px; left:6px; font-size:.8rem;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.6));
}

.sidebar-footer {
  padding: 10px 10px;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex; align-items: center; gap: 6px;
}
.user-chip {
  display: flex; align-items: center; gap: 8px;
  flex: 1; border-radius: 7px; padding: 6px 8px;
  color: var(--sb-text); text-decoration: none;
  transition: background var(--transition);
  min-width: 0;
}
.user-chip:hover { background: var(--sb-hover); color: #fff; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; font-size: .8rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-info { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-size: .82rem; font-weight: 600; color: #fff; truncate: true; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: .7rem; color: var(--sb-muted); }
.logout-btn {
  background: none; border: none; cursor: pointer;
  color: var(--sb-muted); padding: 6px; border-radius: 6px;
  display: flex; align-items: center;
}
.logout-btn svg { width: 16px; height: 16px; }
.logout-btn:hover { color: var(--c-danger); background: rgba(220,38,38,.1); }

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  height: var(--tb-h); background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center;
  padding: 0 20px; gap: 12px;
  position: sticky; top: 0; z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 6px; }
.btn-icon {
  background: none; border: none; cursor: pointer;
  width: 34px; height: 34px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--c-muted); transition: background var(--transition), color var(--transition);
}
.btn-icon svg { width: 18px; height: 18px; }
.btn-icon:hover { background: var(--c-surface2); color: var(--c-text); }
#mobileSidebarToggle {
  display: none;
  width: 44px;
  height: 44px;
}

/* Breadcrumb */
.breadcrumb {
  display: flex; align-items: center; gap: 4px;
  font-size: .82rem; color: var(--c-muted); flex-wrap: nowrap;
  overflow: hidden;
}
.breadcrumb a { color: var(--c-muted); }
.breadcrumb a:hover { color: var(--c-accent); text-decoration: none; }
.breadcrumb span:last-child { color: var(--c-text); font-weight: 500; }
.bc-sep { opacity: .4; }

/* ── Main Content ─────────────────────────────────────────── */
.main-content { flex: 1; padding: 24px; width: 100%; min-width: 0; box-sizing: border-box; overflow-x: auto; }

/* ── Flash Messages ───────────────────────────────────────── */
.flash {
  margin: 0 24px 0; padding: 12px 16px;
  border-radius: var(--radius); font-size: .875rem;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; border-left: 4px solid;
}
.flash-success { background: #f0fdf4; border-color: var(--c-success); color: #166534; }
.flash-error   { background: #fef2f2; border-color: var(--c-danger);  color: #991b1b; }
.flash-warning { background: #fffbeb; border-color: var(--c-warning);  color: #92400e; }
.flash-info    { background: #eff6ff; border-color: var(--c-info);    color: #1e40af; }
[data-theme="dark"] .flash-success { background: rgba(22,163,74,.1); color: #86efac; }
[data-theme="dark"] .flash-error   { background: rgba(220,38,38,.1);  color: #fca5a5; }
.flash button { background: none; border: none; cursor: pointer; opacity: .6; font-size: 1rem; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.card-title { font-size: .95rem; font-weight: 600; }
.card-body { padding: 20px; }

/* ── File Grid ────────────────────────────────────────────── */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}
.file-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  overflow: hidden; cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  position: relative; user-select: none;
}
.file-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--c-accent);
}
.file-card.selected {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px rgba(79,70,229,.2);
}
.file-thumb {
  aspect-ratio: 4/3; background: var(--c-surface2);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative;
}
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-thumb .file-type-icon {
  width: 48px; height: 48px; opacity: .4;
}
.file-thumb .file-ext-badge {
  position: absolute; bottom: 6px; right: 6px;
  background: rgba(0,0,0,.6); color: #fff;
  font-size: .65rem; font-family: var(--font-mono);
  padding: 2px 5px; border-radius: 3px; text-transform: uppercase;
}
.file-info {
  padding: 8px 10px 10px;
}
.file-name {
  font-size: .78rem; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-meta {
  font-size: .7rem; color: var(--c-muted); margin-top: 2px;
  display: flex; align-items: center; gap: 6px;
}
.file-card-check {
  position: absolute; top: 6px; left: 6px;
  width: 18px; height: 18px; border-radius: 4px;
  background: var(--c-accent); color: #fff;
  display: none; align-items: center; justify-content: center;
  font-size: .65rem;
}
.file-card.selected .file-card-check { display: flex; }
.file-delete-btn {
  position: absolute; top: 6px; right: 6px;
  width: 24px; height: 24px; border-radius: 6px;
  background: rgba(0,0,0,.55); color: #fff; border: none;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; cursor: pointer; opacity: 0;
  transition: opacity var(--transition), background var(--transition);
  z-index: 2;
}
.file-card:hover .file-delete-btn { opacity: 1; }
.file-delete-btn:hover { background: var(--c-danger); }
@media (max-width: 768px) {
  .file-delete-btn { opacity: 1; } /* sempre visível em touch */
}

/* ── Folder Grid ──────────────────────────────────────────── */
.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px; margin-bottom: 24px;
}
.folder-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  cursor: pointer; transition: all var(--transition);
  text-decoration: none; color: var(--c-text);
  position: relative;
}
.folder-card:hover {
  border-color: var(--c-accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.folder-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; flex-shrink: 0;
}
.folder-name { font-size: .85rem; font-weight: 600; }
.folder-count { font-size: .72rem; color: var(--c-muted); }
.folder-lock {
  position: absolute; top: 8px; right: 10px;
  font-size: .75rem; color: var(--c-warning); opacity: .7;
}

/* ── Toolbar ──────────────────────────────────────────────── */
.toolbar {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap; margin-bottom: 20px;
}
.toolbar-left  { display: flex; align-items: center; gap: 8px; flex: 1; flex-wrap: wrap; }
.toolbar-right { display: flex; align-items: center; gap: 8px; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 6px; font-size: .83rem;
  font-weight: 500; cursor: pointer; border: 1px solid transparent;
  transition: all var(--transition); white-space: nowrap;
  font-family: var(--font);
}
.btn svg { width: 15px; height: 15px; }
.btn-primary   { background: var(--c-accent); color: #fff; }
.btn-primary:hover   { background: #4338ca; }
.btn-secondary { background: var(--c-surface); color: var(--c-text); border-color: var(--c-border); }
.btn-secondary:hover { background: var(--c-surface2); }
.btn-danger    { background: var(--c-danger); color: #fff; }
.btn-danger:hover    { background: #b91c1c; }
.btn-success   { background: var(--c-success); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: .78rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: .82rem; font-weight: 500;
  margin-bottom: 5px; color: var(--c-text);
}
.form-label.required::after { content: ' *'; color: var(--c-danger); }
.form-control {
  width: 100%; padding: 8px 12px;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--radius); color: var(--c-text);
  font-size: .875rem; font-family: var(--font);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}
.form-control::placeholder { color: var(--c-muted); }
.form-hint { font-size: .75rem; color: var(--c-muted); margin-top: 4px; }
.form-error { font-size: .75rem; color: var(--c-danger); margin-top: 4px; }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* Tags input */
.tags-input {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 6px 10px; min-height: 40px;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--radius); cursor: text;
}
.tags-input:focus-within { border-color: var(--c-accent); box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(79,70,229,.12); color: var(--c-accent);
  padding: 2px 8px; border-radius: 20px; font-size: .75rem; font-weight: 500;
}
.tag-chip button { background: none; border: none; cursor: pointer; color: inherit; font-size: .8rem; line-height: 1; padding: 0 2px; }
.tags-input input { border: none; outline: none; background: none; font-size: .83rem; color: var(--c-text); min-width: 80px; flex: 1; }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--c-border); }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
thead th {
  background: var(--c-surface2); padding: 10px 14px;
  font-weight: 600; font-size: .78rem; text-transform: uppercase;
  letter-spacing: .04em; color: var(--c-muted);
  border-bottom: 1px solid var(--c-border); white-space: nowrap;
  text-align: left;
}
tbody td { padding: 10px 14px; border-bottom: 1px solid var(--c-border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--c-surface2); }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 20px;
  font-size: .72rem; font-weight: 600;
}
.badge-purple  { background: rgba(79,70,229,.12); color: #4f46e5; }
.badge-green   { background: rgba(22,163,74,.12);  color: #16a34a; }
.badge-red     { background: rgba(220,38,38,.12);  color: #dc2626; }
.badge-yellow  { background: rgba(217,119,6,.12);  color: #d97706; }
.badge-gray    { background: var(--c-surface2);    color: var(--c-muted); }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.5); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--c-surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto; position: relative;
}
.modal-close {
  position: absolute; top: 12px; right: 14px;
  background: none; border: none; font-size: 1.3rem;
  cursor: pointer; color: var(--c-muted); line-height: 1;
}
.modal-close:hover { color: var(--c-text); }
.modal-header { padding: 20px 24px 0; }
.modal-title  { font-size: 1rem; font-weight: 700; }
.modal-body   { padding: 16px 24px 24px; }

/* ── Toasts ───────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 8px; z-index: 300;
}
.toast {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 10px 16px; font-size: .84rem;
  display: flex; align-items: center; gap: 8px;
  min-width: 260px; animation: toastIn .2s ease;
}
.toast-success { border-left: 3px solid var(--c-success); }
.toast-error   { border-left: 3px solid var(--c-danger); }
.toast-info    { border-left: 3px solid var(--c-accent); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } }

/* ── Upload Zone ──────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--c-border); border-radius: var(--radius-lg);
  padding: 40px 20px; text-align: center;
  cursor: pointer; transition: all var(--transition);
  color: var(--c-muted);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--c-accent); background: rgba(79,70,229,.04);
  color: var(--c-accent);
}
.upload-zone svg { width: 40px; height: 40px; margin-bottom: 10px; opacity: .5; }
.upload-zone p { font-size: .875rem; }
.upload-zone strong { color: var(--c-accent); }


/* ── OCR Review ───────────────────────────────────────────── */
.ocr-layout {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
}
.ocr-image-pane { position: sticky; top: 20px; }
.ocr-image-pane img { width: 100%; border-radius: var(--radius); box-shadow: var(--shadow); }
.ocr-text-pane textarea {
  width: 100%; min-height: 500px;
  font-family: var(--font-mono); font-size: .82rem;
  line-height: 1.6; resize: vertical;
}
.ocr-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .72rem; font-weight: 600; padding: 3px 8px;
  border-radius: 20px;
}
.ocr-badge.pending    { background: rgba(217,119,6,.12);  color: #d97706; }
.ocr-badge.processing { background: rgba(37,99,235,.12);  color: #2563eb; }
.ocr-badge.done       { background: rgba(22,163,74,.12);  color: #16a34a; }
.ocr-badge.failed     { background: rgba(220,38,38,.12);  color: #dc2626; }
.ocr-badge.reviewed   { background: rgba(79,70,229,.12);  color: #4f46e5; }

/* ── Viewer ───────────────────────────────────────────────── */
.viewer-wrapper {
  background: #1a1a2e; border-radius: var(--radius-lg);
  overflow: hidden; min-height: 600px;
  display: flex; align-items: center; justify-content: center;
}
.viewer-wrapper img {
  max-width: 100%; max-height: 80vh;
  object-fit: contain;
}
.viewer-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 0; margin-bottom: 10px;
}

/* ── Stats ────────────────────────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr));
  gap: 14px; margin-bottom: 24px;
}
.stat-card {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--radius-lg); padding: 16px 20px;
}
.stat-label { font-size: .75rem; color: var(--c-muted); text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--c-text); line-height: 1.2; margin-top: 4px; }
.stat-change { font-size: .75rem; color: var(--c-muted); margin-top: 4px; }

/* ── Login Page ───────────────────────────────────────────── */
.login-page {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #1e1b4b 100%);
}
.login-box {
  width: 100%; max-width: 380px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 16px; padding: 40px;
  backdrop-filter: blur(20px);
}
.login-logo {
  text-align: center; margin-bottom: 28px;
}
.login-logo .logo-icon {
  width: 52px; height: 52px; margin: 0 auto 12px;
  font-size: 1.6rem;
}
.login-logo h1 { color: #fff; font-size: 1.5rem; font-weight: 800; }
.login-logo p  { color: rgba(255,255,255,.5); font-size: .82rem; margin-top: 4px; }
.login-box .form-label { color: rgba(255,255,255,.7); }
.login-box .form-control {
  background: rgba(255,255,255,.07);
  border-color: rgba(255,255,255,.1);
  color: #fff;
}
.login-box .form-control:focus { border-color: #818cf8; }
.login-box .form-control::placeholder { color: rgba(255,255,255,.3); }
.login-box .btn-primary { width: 100%; justify-content: center; background: #6366f1; }
.login-box .btn-primary:hover { background: #4f46e5; }
.login-footer { text-align: center; margin-top: 16px; }
.login-footer a { color: rgba(255,255,255,.5); font-size: .8rem; }
.login-footer a:hover { color: #fff; }

/* ── Print ────────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .toolbar, #ss-shield,
  .btn, .modal-overlay, #toast-container { display: none !important; }
  .main-wrapper { margin: 0 !important; }
  .main-content { padding: 0 !important; }
  body { background: #fff !important; }
  .file-grid { grid-template-columns: repeat(3, 1fr) !important; }
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main-wrapper { margin-left: 0 !important; }
  #mobileSidebarToggle { display: flex; }
  .ocr-layout { grid-template-columns: 1fr; }
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .main-content { padding: 16px; }
}

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

/* ── Utilities ────────────────────────────────────────────── */
.d-flex     { display: flex; }
.gap-2      { gap: 8px; }
.gap-3      { gap: 12px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-muted { color: var(--c-muted); }
.text-sm    { font-size: .82rem; }
.text-xs    { font-size: .75rem; }
.fw-600     { font-weight: 600; }
.fw-700     { font-weight: 700; }
.mb-0       { margin-bottom: 0; }
.mb-1       { margin-bottom: 6px; }
.mb-2       { margin-bottom: 12px; }
.mb-3       { margin-bottom: 20px; }
.mb-4       { margin-bottom: 28px; }
.mt-2       { margin-top: 10px; }
.mt-3       { margin-top: 18px; }
.p-3        { padding: 16px; }
.w-100      { width: 100%; }
.truncate   { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-title { font-size: 1.35rem; font-weight: 700; margin-bottom: 20px; }
.section-title { font-size: .9rem; font-weight: 600; color: var(--c-muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 12px; }
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--c-muted);
}
.empty-state svg { width: 56px; height: 56px; opacity: .3; margin-bottom: 12px; }
.empty-state p { font-size: .9rem; }
.spinner {
  width: 20px; height: 20px; border: 2px solid var(--c-border);
  border-top-color: var(--c-accent); border-radius: 50%;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
