:root {
  --primary: #16A34A; /* Vert moderne */
  --primary-light: #D1FAE5; /* Vert très clair */
  --primary-dark: #0C743A; /* Vert foncé */
  --accent: #484848;
  --bg: #ffffff;
  --bg2: #ffffff;
  --bg3: #f7f7f7;
  --text: #222222;
  --text2: #717171;
  --muted: #b0b0b0;
  --border: #DDDDDD;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.08);
  --shadow: 0 6px 20px rgba(0,0,0,0.1);
  --shadow-lg: 0 12px 30px rgba(0,0,0,0.15);
  --radius: 12px;
  --radius-sm: 8px;
}
body.dark-mode {
  --bg: #121212;
  --bg2: #222222;
  --bg3: #333333;
  --text: #f8fafc;
  --text2: #b0b0b0;
  --muted: #717171;
  --border: #484848;
  --primary-light: rgba(22,163,74,0.15); /* RGBA du nouveau vert */
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.2);
  --shadow: 0 8px 32px rgba(0,0,0,0.3);
}
* { margin:0; padding:0; box-sizing:border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Sora', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: transparent;
}
body.rtl { direction: rtl; font-family: 'Noto Naskh Arabic', 'Sora', sans-serif; }

/* ── NAVBAR ── */
.navbar {
  position: fixed; top:0; left:0; right:0;
  background: var(--bg2);
  border-bottom: 1px solid #ebebeb;
  height: 80px;
  display: flex; align-items: center;
  padding: 0 2rem; gap: 1rem;
  z-index: 300;
}
.nav-logo {
  display: flex; align-items: center; gap: 0.6rem;
  font-size: 1.15rem; font-weight: 700;
  color: var(--primary); text-decoration: none;
}
.nav-logo-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; color: white;
}
.nav-center {
  flex: 1;
  display: flex; justify-content: center;
}
.nav-search {
  display: flex; align-items: center;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 0.6rem 1.2rem;
  gap: 0.5rem;
  width: min(400px, 100%);
  transition: box-shadow 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.05);
}
.nav-search:focus-within {
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
  border-color: transparent;
}
.nav-search-icon-circle {
  background: var(--primary);
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white;
}
.nav-search input {
  border: none; background: transparent;
  font-family: inherit; font-size: 0.9rem;
  color: var(--text); outline: none; flex: 1;
}
.nav-search input::placeholder { color: var(--muted); }
.nav-search svg { color: var(--muted); flex-shrink: 0; }
.nav-right { display: flex; align-items: center; gap: 0.6rem; }
.theme-toggle {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px; height: 36px;
  border-radius: 10px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.theme-toggle:hover { border-color: var(--primary); }
.lang-pill {
  display: flex;
  background: var(--bg3);
  border-radius: 100px;
  padding: 3px;
  border: 1px solid var(--border);
}
.lang-opt {
  padding: 0.25rem 0.7rem;
  border-radius: 100px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  transition: all 0.2s;
}
.lang-opt.active {
  background: var(--primary);
  color: white;
}
.upload-nav-btn {
  display: flex; align-items: center; gap: 0.4rem;
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.45rem 0.8rem;
  border-radius: 100px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
  user-select: none;
}
.upload-nav-btn:hover { background: var(--primary-dark); transform: translateY(-1px); }
.upload-nav-btn:active { transform: scale(0.96); }

/* ── HERO ── */
.hero {
  margin-top: 80px;
  background: #ffffff;
  padding: 5rem 2rem;
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid #ebebeb;
}
.hero-container {
  max-width: 850px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 2rem;
  position: relative;
  z-index: 1;
  text-align: center;
}
.hero-content {
  text-align: center;
  flex: 1;
}
body.rtl .hero-content {
  text-align: right;
}
body.rtl .hero-container {
  flex-direction: column;
}
.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
  margin: 0;
  text-shadow: none;
  letter-spacing: -0.03em;
}
.hero-stats {
  display: flex;
  flex-direction: row;
  gap: 1rem;
  margin-top: 1.5rem;
}
.hero-stat { 
  text-align: center; 
  background: var(--bg3); 
  padding: 0.4rem 1rem; 
  border-radius: 100px; 
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.hero-stat-num {
  font-size: 1.1rem; font-weight: 700;
  color: var(--text); line-height: 1;
}
.hero-stat-label {
  font-size: 0.7rem;
  color: var(--text2);
  margin: 0;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ── CATEGORIES ── */
.cats-wrap {
  max-width: 1200px; margin: 0 auto;
  padding: 2rem 2rem 0;
}
.cats-scroll {
  display: flex; gap: 0.6rem;
  overflow-x: auto; 
  padding: 0.5rem 0.2rem 1rem;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}
.cats-scroll::-webkit-scrollbar { display: none; }
.cat-btn {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 1rem 0;
  margin: 0 1.2rem;
  border-radius: 0;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text2);
  font-size: 0.85rem; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  font-family: inherit;
  transition: all 0.2s;
  scroll-snap-align: start;
}
.cat-btn:hover { border-bottom-color: #dddddd; color: var(--text); }
.cat-btn.active {
  border-bottom-color: var(--text);
  color: var(--text);
}
.cat-btn .cat-count {
  background: rgba(0,0,0,0.1);
  padding: 0.1rem 0.4rem;
  border-radius: 100px;
  font-size: 0.72rem;
}
.cat-btn.active .cat-count { background: rgba(255,255,255,0.25); }

/* ── MAIN CONTENT ── */
.main {
  max-width: 1200px; margin: 0 auto;
  padding: 1.5rem 2rem 4rem;
}
.section-bar {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 1.2rem; flex-wrap: wrap; gap: 0.5rem;
}
.section-title { font-size: 1.4rem; font-weight: 800; letter-spacing: -0.02em; }
.results-count { font-size: 0.85rem; color: var(--muted); }
.sort-select {
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text2);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer; outline: none;
}

/* ── DOC GRID ── */
.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 1.5rem 1rem;
}
.doc-card {
  background: var(--bg2);
  border: 1px solid var(--border) !important;
  border-radius: var(--radius);
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
  position: relative;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-sm);
  animation: cardIn 0.4s ease both;
}
@keyframes cardIn {
  from { opacity:0; transform:translateY(15px); }
  to { opacity:1; transform:translateY(0); }
}
.doc-card:hover {
  box-shadow: none;
  transform: translateY(-4px);
}
.doc-card-top {
  position: relative;
  background: var(--bg3);
  width: 42px;
  height: 42px;
  border-radius: 10px;
  margin: 1rem 1rem 0.5rem;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.2s ease, background 0.3s ease;
}
.doc-card:hover .doc-card-top { background: #e5e5e5; }
.doc-icon {
  font-size: 1.2rem;
  color: var(--text);
}
.doc-content-info {
  padding: 0 0.25rem;
  display: flex; flex-direction: column; flex: 1;
}
.icon-pdf  { background: transparent; }
.icon-word { background: transparent; }
.icon-ppt  { background: transparent; }
.icon-other { background: transparent; }
.icon-image { background: transparent; }
.icon-zip   { background: transparent; }

.doc-actions-top { 
  display: flex; gap: 0.4rem; 
  position: absolute; top: 1rem; right: 1rem;
  z-index: 5;
}
.fav-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  cursor: pointer; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.fav-btn:hover, .fav-btn.active { border-color: #f97316; background: #fff7ed; }
.share-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  cursor: pointer; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
  color: var(--text2);
}
@keyframes highlightDoc {
  0% { box-shadow: 0 0 0 4px var(--primary); transform: scale(1.02); }
  100% { box-shadow: var(--shadow-sm); transform: scale(1); }
}
.doc-card.highlight {
  scroll-margin-top: 100px;
  animation: highlightDoc 2s ease-out;
  border-color: var(--primary);
}
.share-btn:hover { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.doc-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  text-transform: uppercase;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.badge-pdf  { background: #000000; color: #ffffff; }
.badge-word { background: #000000; color: #ffffff; }
.badge-ppt  { background: #000000; color: #ffffff; }
.badge-image { background: #000000; color: #ffffff; }
.badge-zip   { background: #000000; color: #ffffff; }
.badge-other { background: #000000; color: #ffffff; }
.doc-cat-badge {
  display: inline-block;
  font-size: 0.7rem; font-weight: 500;
  padding: 0.15rem 0.5rem; border-radius: 5px;
  background: var(--primary-light); color: var(--primary);
  margin-bottom: 0.5rem; margin-right: 0.3rem;
}
.doc-title {
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.2rem;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  color: var(--text);
}
.doc-card-meta-lite {
  font-size: 0.72rem;
  color: var(--text2);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 1px;
  opacity: 0.8;
}
.doc-card-meta-lite .sep {
  color: var(--muted);
  font-size: 0.6rem;
  margin: 0 1px;
}
.doc-desc {
  display: none; /* Masqué pour le style catalogue LiteAPKs */
}
.doc-meta {
  display: flex; align-items: center; gap: 0.5rem;
  flex-wrap: wrap; margin-bottom: 1rem;
}
.doc-meta-item {
  display: flex; align-items: center; gap: 0.25rem;
  font-size: 0.75rem; color: var(--muted);
}
.doc-footer {
  display: flex; flex-direction: column; 
  gap: 0.5rem; margin-top: auto; padding: 0.75rem;
}
.btn-preview {
  width: 100%;
  padding: 0.65rem;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text2);
  border-radius: var(--radius-sm);
  cursor: pointer; font-size: 0.83rem;
  font-family: inherit; font-weight: 500;
  transition: all 0.2s;
  display: flex; align-items: center; justify-content: center; gap: 0.3rem;
  user-select: none;
}
.btn-preview:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.btn-preview:active { background: var(--border); transform: scale(0.98); }
.btn-download {
  width: 100%;
  padding: 0.65rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer; font-size: 0.83rem;
  font-family: inherit; font-weight: 600;
  transition: all 0.2s;
  display: flex; align-items: center; justify-content: center; gap: 0.3rem;
  user-select: none;
}
.btn-download:hover { background: var(--primary-dark); }
.btn-download:active { transform: scale(0.98); }
.dl-count {
  font-size: 0.72rem;
  background: rgba(255,255,255,0.25);
  padding: 0.1rem 0.4rem;
  border-radius: 100px;
}
.no-results {
  grid-column: 1/-1;
  text-align: center; padding: 4rem 2rem;
  color: var(--muted);
}
.no-results-icon { font-size: 3rem; margin-bottom: 1rem; }
.no-results h3 { font-size: 1.1rem; margin-bottom: 0.5rem; color: var(--text2); }

/* ── MODAL PREVIEW ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,22,35,0.6);
  backdrop-filter: blur(6px);
  z-index: 500;
  display: none; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg2);
  border-radius: var(--radius);
  width: min(900px, 100%);
  max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalIn 0.3s ease;
}
@keyframes modalIn {
  from { opacity:0; transform:scale(0.95); }
  to { opacity:1; transform:scale(1); }
}
.modal-header {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1rem; font-weight: 600; flex: 1; }
.modal-close {
  width: 36px; height: 36px;
  border-radius: 8px; border: 1.5px solid var(--border);
  background: var(--bg); cursor: pointer; font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.modal-close:hover { background: #fff1f1; border-color: #dc2626; color: #dc2626; }
.modal-body { flex: 1; overflow: hidden; }
.modal-body iframe {
  width: 100%; height: 100%;
  min-height: 500px; border: none;
}
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex; gap: 0.7rem; justify-content: flex-end;
}

/* ── UPLOAD MODAL ── */
.upload-modal {
  background: var(--bg2);
  border-radius: var(--radius);
  width: min(560px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.3s ease;
  overflow: hidden;
}
.upload-modal-body {
  overflow-y: auto;
  flex: 1;
}
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  margin: 1.2rem;
}
.upload-zone:hover, .upload-zone.drag { border-color: var(--primary); background: var(--primary-light); }
.upload-zone-icon { font-size: 2.5rem; margin-bottom: 0.8rem; }
.upload-zone h3 { font-size: 1rem; font-weight: 600; margin-bottom: 0.4rem; }
.upload-zone p { font-size: 0.85rem; color: var(--muted); }
.upload-form { padding: 0 1.2rem 1.2rem; display: flex; flex-direction: column; gap: 0.8rem; }
.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
.form-label { font-size: 0.85rem; font-weight: 500; color: var(--text2); }
.form-input, .form-select, .form-textarea {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.9rem;
  font-family: inherit; font-size: 0.9rem;
  color: var(--text); background: var(--bg);
  outline: none; transition: border-color 0.2s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--primary); }
.form-textarea { resize: vertical; min-height: 70px; }
.gdrive-help {
  background: var(--primary-light);
  border: 1px solid rgba(26,108,247,0.2);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1rem;
  font-size: 0.82rem;
  color: var(--primary-dark);
  line-height: 1.6;
}
.gdrive-help strong { display: block; margin-bottom: 0.3rem; }
.btn-primary {
  background: var(--primary); color: white;
  border: none; padding: 0.7rem 1.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: background 0.2s;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary {
  background: var(--bg3); color: var(--text2);
  border: 1.5px solid var(--border); padding: 0.7rem 1.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem; font-weight: 500;
  cursor: pointer; font-family: inherit;
  transition: all 0.2s;
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }

/* ── TOAST ── */
.toast {
  position: fixed; bottom: 2rem; right: 2rem;
  background: var(--text);
  color: white;
  padding: 0.85rem 1.3rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  box-shadow: var(--shadow-lg);
  transform: translateY(100px); opacity: 0;
  transition: all 0.35s cubic-bezier(0.4,0,0.2,1);
  z-index: 999; max-width: 320px;
  display: flex; align-items: center; gap: 0.5rem;
}
.toast.show { transform: translateY(0); opacity: 1; }
body.rtl .toast { right: auto; left: 2rem; }

/* ── FAVORITES PAGE ── */
.fav-empty {
  text-align: center; padding: 4rem 2rem;
  color: var(--muted);
}
.fav-empty-icon { font-size: 3rem; margin-bottom: 1rem; }

/* ── FOOTER ── */
footer {
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 2rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
}
footer a { color: var(--primary); text-decoration: none; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .navbar { 
    height: auto; 
    padding: 0.6rem 1rem; 
    flex-wrap: wrap; 
    justify-content: space-between; 
  }
  .nav-logo img { height: 28px !important; }
  .nav-center { 
    display: block; 
    order: 3; 
    width: 100%; 
    margin-top: 0.6rem; 
  }
  .nav-search { 
    width: 100%; 
    max-width: none; 
    height: 40px;
  }
  .nav-search input { font-size: 1rem; }
  .hero { 
    margin-top: 180px;
    padding: 2rem 1rem;
  }
  .hero-container, body.rtl .hero-container {
    flex-direction: column;
    text-align: center;
    gap: 1.5rem;
  }
  .hero-content, body.rtl .hero-content { text-align: center; }
  .hero h1 { font-size: 1.3rem; }
  .hero-stats {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    gap: 0.5rem;
  }
  .hero-stat { flex: 1; min-width: 125px; padding: 0.4rem; }
  .main { padding: 1rem 1rem 3rem; }
  .cats-wrap { padding: 1.5rem 1rem 0; }
  .doc-grid { grid-template-columns: 1fr; }
  .nav-right .upload-nav-btn span { display: none; }
  .upload-nav-btn { padding: 0.45rem 0.6rem; font-size: 1.1rem; }
  
  .upload-section { padding: 1.5rem 1rem !important; }
  .upload-title { font-size: 1rem; }

  .doc-footer { flex-direction: column; }
  .btn-preview, .btn-download { width: 100%; padding: 0.75rem; font-size: 0.9rem; }

  .modal, .upload-modal, .admin-panel {
    width: 100%; height: 100%; max-height: 100vh;
    border-radius: 0;
  }
  .modal-body iframe { min-height: 70vh; }
}

/* ── ADMIN PANEL ── */
.admin-overlay {
  position: fixed; inset: 0;
  background: rgba(15,22,35,0.7);
  backdrop-filter: blur(8px);
  z-index: 600;
  display: none; align-items: center; justify-content: center;
  padding: 1rem;
}
.admin-overlay.open { display: flex; }
.admin-panel {
  background: var(--bg2);
  border-radius: var(--radius);
  width: min(860px, 100%);
  max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.3s ease;
  overflow: hidden;
}
.admin-panel.full-page {
  width: 100% !important;
  height: 100vh !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
}
.admin-header {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--text);
  color: white; flex-shrink: 0;
}
.admin-header-title { font-size: 1rem; font-weight: 700; flex: 1; }
.admin-close {
  width: 34px; height: 34px;
  border-radius: 8px; border: 1.5px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.1); cursor: pointer; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  color: white; transition: all 0.2s;
}
.admin-close:hover { background: rgba(255,255,255,0.2); }
.admin-login {
  padding: 2.5rem;
  display: flex; flex-direction: column; align-items: center; gap: 1rem;
  text-align: center;
}
.admin-login-icon { font-size: 3rem; }
.admin-login h3 { font-size: 1.1rem; font-weight: 700; }
.admin-login p { font-size: 0.85rem; color: var(--muted); }
.admin-pwd-wrap {
  display: flex; gap: 0.5rem; width: 100%; max-width: 320px;
}
.admin-pwd-input {
  flex: 1; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 1rem; font-family: inherit;
  font-size: 0.95rem; color: var(--text);
  background: var(--bg); outline: none;
  transition: border-color 0.2s;
}
.admin-pwd-input:focus { border-color: var(--primary); }
.admin-login-err {
  font-size: 0.82rem; color: #dc2626;
  display: none;
}
.admin-login-err.show { display: block; }
.admin-body {
  overflow-y: auto; flex: 1; padding: 1.2rem 1.5rem;
  min-height: 0;
}
.admin-stats-row {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px,1fr));
  gap: 0.8rem; margin-bottom: 1.5rem;
}
.admin-stat-card {
  background: #ffffff; 
  border-radius: 16px;
  padding: 1.5rem; text-align: left;
  border: 1px solid #ebebeb;
  box-shadow: 0 6px 16px rgba(0,0,0,0.05);
}
.admin-stat-card .num {
  font-size: 1.8rem; font-weight: 700;
  color: var(--primary); line-height: 1;
}
.admin-stat-card .lbl {
  font-size: 0.75rem; color: var(--muted);
  margin-top: 0.3rem;
}
.admin-section-title {
  font-size: 1rem; font-weight: 700;
  margin-bottom: 1rem; padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 0.5rem;
}
.admin-table {
  width: 100%; border-collapse: collapse;
  font-size: 0.85rem;
}
.admin-table th {
  text-align: left; padding: 0.6rem 0.8rem;
  background: var(--bg); color: var(--muted);
  font-size: 0.75rem; font-weight: 600;
  letter-spacing: 0.05em; text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.admin-table td {
  padding: 0.75rem 0.8rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  transition: background 0.2s;
}
.admin-table tr:hover td { background: var(--primary-light); }
.admin-table tr:last-child td { border-bottom: none; }
.admin-doc-title-cell { font-weight: 500; max-width: 200px; }
.admin-doc-title-cell small { display: block; color: var(--muted); font-size: 0.75rem; font-weight: 400; }
.admin-actions { display: flex; gap: 0.4rem; }
.btn-edit {
  padding: 0.4rem 0.8rem; 
  border-radius: var(--radius-sm);
  border: 1px solid var(--border); 
  background: var(--bg2);
  color: var(--primary); font-size: 0.78rem;
  cursor: pointer; font-family: inherit; font-weight: 600;
  transition: all 0.2s;
}
.btn-edit:hover { background: var(--primary-light); border-color: var(--primary); }
.btn-delete {
  padding: 0.4rem 0.8rem; 
  border-radius: var(--radius-sm);
  border: 1px solid #fecaca; background: #fff1f1;
  color: #dc2626; font-size: 0.78rem;
  cursor: pointer; font-family: inherit; font-weight: 600;
  transition: all 0.2s;
}
.btn-delete:hover { background: #dc2626; color: white; border-color: #dc2626; }
.dl-bar-wrap { width: 80px; }
.dl-bar {
  height: 6px; border-radius: 3px;
  background: var(--border); overflow: hidden;
}
.dl-bar-fill { height: 100%; background: var(--primary); border-radius: 3px; }
.admin-edit-form {
  background: var(--bg3); border-radius: var(--radius-sm);
  padding: 1.2rem; margin-bottom: 1rem;
  border: 1.5px solid var(--primary);
  display: none; 
  flex-direction: column; 
  gap: 0.8rem;
  animation: modalIn 0.3s ease-out;
}
.admin-edit-form.open { display: flex; }
.admin-edit-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.admin-logout {
  display: flex; justify-content: flex-end;
  padding: 0.8rem 1.5rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.btn-logout {
  padding: 0.4rem 1rem; border-radius: 5px;
  border: 1.5px solid var(--border); background: var(--bg);
  color: var(--muted); font-size: 0.82rem;
  cursor: pointer; font-family: inherit;
  transition: all 0.2s;
}
.btn-logout:hover { color: #dc2626; border-color: #dc2626; }
.sample-badge {
  font-size: 0.68rem; padding: 0.1rem 0.4rem;
  background: var(--bg3); color: var(--muted);
  border-radius: 4px; border: 1px solid var(--border);
}
@media (max-width: 640px) {
  .admin-table thead { display: none; }
  .admin-table tr { 
    display: block; 
    border: 1px solid var(--border); 
    margin-bottom: 1rem; 
    border-radius: var(--radius-sm);
    background: var(--bg2);
  }
  .admin-table td { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 0.6rem 0.8rem;
    text-align: right;
  }
  .admin-table td::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: 0.7rem;
    color: var(--muted);
    text-transform: uppercase;
  }
  .admin-edit-row { grid-template-columns: 1fr; }
  .dl-bar-wrap { display: none; }
}

@keyframes uploadPulse {
  0% { opacity: 1; }
  50% { opacity: 0.6; }
  100% { opacity: 1; }
}
.upload-progress-container {
  width: 100%; max-width: 320px; height: 6px; background: var(--bg3); 
  border-radius: 100px; margin: 1rem auto 0; overflow: hidden; border: 1px solid var(--border);
}
.upload-progress-fill {
  height: 100%; background: var(--primary); width: 0%; border-radius: 100px;
  transition: width 0.2s ease-out;
}
.upload-progress-fill.complete {
  background: #16a34a;
}
.upload-section.drag-active {
  border-color: var(--primary) !important;
  background: var(--primary-light) !important;
  transform: scale(1.01);
  box-shadow: var(--shadow);
}
.admin-dashboard-layout {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ── DIRECT UPLOAD ZONE IMPROVEMENTS ── */
.direct-upload-zone {
  background: var(--bg2);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 2rem;
  text-align: center;
  transition: all 0.2s;
}
.direct-upload-title {
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--primary);
}
.direct-upload-desc {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1.2rem;
}
.direct-upload-password-wrap {
  max-width: 300px;
  margin: 0 auto 1.2rem;
}
.direct-upload-password { text-align: center; width: 100%; }
.direct-upload-btn-label { display: inline-flex; cursor: pointer; }
.direct-upload-progress-box {
  display: none;
  margin-top: 1.5rem;
  max-width: 320px;
  margin-inline: auto;
}
.progress-stats {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
  font-size: 0.72rem;
  color: var(--muted);
}
/* Admin & Utilities */
.admin-search-input-wrap { width: 100%; border-radius: var(--radius-sm); }
.batch-toolbar {
  display: none; 
  position: sticky; 
  top: 50px; 
  z-index: 20; 
  background: var(--primary); 
  color: white; 
  padding: 0.7rem 1.2rem; 
  border-radius: var(--radius-sm); 
  margin-bottom: 1rem; 
  align-items: center; 
  gap: 1rem; 
  animation: modalIn 0.2s ease;
}
.batch-count { font-size: 0.85rem; font-weight: 600; flex: 1; }
.batch-actions { display: flex; gap: 0.5rem; align-items: center; }
.batch-select { padding: 0.3rem; font-size: 0.75rem; width: 140px; }
.batch-delete-btn { background: white; border: none; padding: 0.4rem 0.8rem; }

.sync-result-box { margin-top: 0.8rem; padding: 0.75rem 1rem; border-radius: 6px; font-size: 0.82rem; line-height: 1.6; }
.table-container { overflow-x: auto; }
.form-actions { display: flex; gap: 0.7rem; }
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.text-center { text-align: center; }

.logo-img { height: 36px; width: auto; }
.load-more-container { text-align: center; margin-top: 3rem; display: none; }
.load-more-btn { padding: 0.8rem 2.5rem; font-weight: 600; }

.sync-box {
  background: var(--bg3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.2rem;
  margin-bottom: 1.5rem;
}
.sync-title { font-size: 0.9rem; font-weight: 700; margin-bottom: 0.8rem; display: flex; align-items: center; gap: 0.5rem; }
.sync-row { display: flex; gap: 0.7rem; flex-wrap: wrap; align-items: flex-end; }
.sync-field { display: flex; flex-direction: column; gap: 0.3rem; flex: 1; min-width: 140px; }
.sync-field label { font-size: 0.75rem; color: var(--muted); }
.sync-field .form-input, .sync-field .form-select { font-size: 0.85rem; width: 100%; }

.log-cleanup-box {
  background: rgba(220,38,38,0.05);
  border: 1.5px solid #fecaca;
  border-radius: var(--radius-sm);
  padding: 1rem 1.2rem;
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.log-cleanup-title { font-size: 0.9rem; font-weight: 700; color: #dc2626; }
.log-cleanup-text { font-size: 0.75rem; color: var(--muted); }
.admin-search-wrap { margin-bottom: 1.5rem; position: sticky; top: 0; z-index: 10; background: var(--bg2); padding-bottom: 10px; }