:root {
  --blue-dark: #1a3a6e;
  --blue-mid: #1e4fa0;
  --blue-light: #2d6cc0;
  --blue-accent: #3d8ef0;
  --gold: #f5a623;
  --gold-dark: #d4891a;
  --gray-bg: #f4f6f9;
  --gray-border: #dce2ec;
  --text-main: #1a1f2e;
  --text-muted: #5a6580;
  --white: #ffffff;
  --radius: 8px;
  --shadow: 0 2px 12px rgba(26,58,110,0.10);
  --shadow-hover: 0 6px 24px rgba(26,58,110,0.18);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--gray-bg);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }

/* ── HEADER ── */
.header {
  background: linear-gradient(135deg, var(--blue-dark) 0%, var(--blue-mid) 100%);
  color: var(--white);
  box-shadow: 0 2px 16px rgba(0,0,0,0.25);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 70px;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
}

.logo {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-emblem {
  width: 50px;
  height: 50px;
  background: var(--white);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  flex-shrink: 0;
}

.logo-text h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3px;
  line-height: 1.2;
}

.logo-text p {
  font-size: 11px;
  opacity: 0.8;
  margin-top: 1px;
}

.header-nav {
  display: flex;
  gap: 4px;
}

.nav-btn {
  padding: 8px 16px;
  border-radius: var(--radius);
  color: rgba(255,255,255,0.85);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  cursor: pointer;
  border: none;
  background: none;
}

.nav-btn:hover,
.nav-btn.active {
  background: rgba(255,255,255,0.15);
  color: var(--white);
}

.btn-upload-nav {
  background: var(--gold);
  color: var(--blue-dark) !important;
  font-weight: 700;
  padding: 8px 20px;
  margin-left: 8px;
}

.btn-upload-nav:hover {
  background: var(--gold-dark) !important;
}

/* ── HERO BANNER ── */
.hero {
  background: linear-gradient(135deg, var(--blue-dark) 0%, var(--blue-light) 100%);
  color: var(--white);
  padding: 48px 24px;
  text-align: center;
}

.hero h2 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 10px;
}

.hero p {
  font-size: 16px;
  opacity: 0.85;
  margin-bottom: 28px;
}

.search-bar {
  display: flex;
  max-width: 640px;
  margin: 0 auto;
  background: var(--white);
  border-radius: 50px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.search-bar input {
  flex: 1;
  border: none;
  outline: none;
  padding: 14px 20px;
  font-size: 15px;
  color: var(--text-main);
  background: transparent;
}

.search-bar button {
  background: var(--gold);
  border: none;
  padding: 14px 28px;
  font-size: 15px;
  font-weight: 600;
  color: var(--blue-dark);
  cursor: pointer;
  transition: background 0.2s;
}

.search-bar button:hover { background: var(--gold-dark); }

/* ── STATS BAR ── */
.stats-bar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-border);
  padding: 12px 24px;
}

.stats-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.stat-item strong {
  color: var(--blue-dark);
  font-size: 18px;
  font-weight: 700;
}

/* ── MAIN LAYOUT ── */
.main-container {
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
  padding: 28px 24px;
  flex: 1;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  align-items: start;
}

/* ── SIDEBAR ── */
.sidebar {
  position: sticky;
  top: 86px;
}

.sidebar-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.sidebar-title {
  background: var(--blue-dark);
  color: var(--white);
  padding: 14px 18px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.category-list {
  list-style: none;
}

.category-item {
  border-bottom: 1px solid var(--gray-border);
}

.category-item:last-child { border: none; }

.category-btn {
  width: 100%;
  text-align: left;
  padding: 12px 18px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-main);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.15s;
}

.category-btn:hover { background: var(--gray-bg); color: var(--blue-mid); }

.category-btn.active {
  background: rgba(30,79,160,0.08);
  color: var(--blue-mid);
  font-weight: 600;
  border-left: 3px solid var(--blue-mid);
}

.cat-count {
  background: var(--gray-border);
  color: var(--text-muted);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 20px;
  font-weight: 600;
}

.category-btn.active .cat-count {
  background: var(--blue-mid);
  color: var(--white);
}

/* ── CONTENT AREA ── */
.content-area {}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.results-label {
  font-size: 14px;
  color: var(--text-muted);
}

.results-label strong { color: var(--text-main); }

.view-toggle {
  display: flex;
  gap: 4px;
}

.view-btn {
  padding: 6px 10px;
  border: 1px solid var(--gray-border);
  background: var(--white);
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.15s;
  color: var(--text-muted);
}

.view-btn.active {
  background: var(--blue-dark);
  color: var(--white);
  border-color: var(--blue-dark);
}

/* ── DOCUMENTS GRID ── */
.docs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.docs-grid.list-view {
  grid-template-columns: 1fr;
}

.doc-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: all 0.2s;
  border: 1px solid var(--gray-border);
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.doc-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
  border-color: var(--blue-accent);
}

.docs-grid.list-view .doc-card {
  flex-direction: row;
  transform: none;
}

.doc-card-icon {
  padding: 28px 20px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-bg);
  border-bottom: 1px solid var(--gray-border);
}

.docs-grid.list-view .doc-card-icon {
  border-bottom: none;
  border-right: 1px solid var(--gray-border);
  padding: 16px 20px;
  min-width: 90px;
}

.file-icon {
  width: 64px;
  height: 80px;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  position: relative;
  color: var(--white);
}

.file-icon::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 18px;
  height: 18px;
  background: rgba(255,255,255,0.3);
  clip-path: polygon(0 0, 100% 100%, 100% 0);
}

.docs-grid.list-view .file-icon {
  width: 40px;
  height: 50px;
  font-size: 9px;
}

.icon-pdf  { background: linear-gradient(135deg, #e53e3e, #c53030); }
.icon-word { background: linear-gradient(135deg, #2b6cb0, #2c5282); }
.icon-excel{ background: linear-gradient(135deg, #276749, #22543d); }
.icon-ppt  { background: linear-gradient(135deg, #d97706, #b45309); }
.icon-txt  { background: linear-gradient(135deg, #718096, #4a5568); }
.icon-img  { background: linear-gradient(135deg, #805ad5, #6b46c1); }
.icon-file { background: linear-gradient(135deg, #4a5568, #2d3748); }

.doc-card-body {
  padding: 14px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.doc-category-tag {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--blue-mid);
  background: rgba(30,79,160,0.08);
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 8px;
}

.doc-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.4;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.docs-grid.list-view .doc-title {
  -webkit-line-clamp: 1;
}

.doc-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.doc-card-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--gray-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--gray-bg);
  font-size: 11px;
  color: var(--text-muted);
  gap: 8px;
}

.doc-date { flex: 1; }

.doc-size {
  font-weight: 600;
  color: var(--text-muted);
}

.btn-view-doc {
  background: var(--blue-mid);
  color: var(--white);
  border: none;
  padding: 5px 12px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-view-doc:hover { background: var(--blue-dark); }

/* ── PAGINATION ── */
.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 28px;
}

.page-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--gray-border);
  background: var(--white);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-btn:hover { border-color: var(--blue-mid); color: var(--blue-mid); }
.page-btn.active { background: var(--blue-dark); color: var(--white); border-color: var(--blue-dark); }
.page-btn:disabled { opacity: 0.4; cursor: default; }

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  grid-column: 1/-1;
}

.empty-state .empty-icon { font-size: 64px; margin-bottom: 16px; }
.empty-state h3 { font-size: 20px; color: var(--text-main); margin-bottom: 8px; }

/* ── UPLOAD MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.25s ease;
}

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

.modal-header {
  background: linear-gradient(135deg, var(--blue-dark), var(--blue-mid));
  color: var(--white);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 12px 12px 0 0;
}

.modal-header h3 { font-size: 18px; font-weight: 700; }

.modal-close {
  background: rgba(255,255,255,0.2);
  border: none;
  color: var(--white);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.modal-close:hover { background: rgba(255,255,255,0.35); }

.modal-body { padding: 24px; }

.drop-zone {
  border: 2px dashed var(--blue-accent);
  border-radius: var(--radius);
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: rgba(61,142,240,0.03);
  margin-bottom: 20px;
}

.drop-zone:hover, .drop-zone.dragover {
  background: rgba(61,142,240,0.08);
  border-color: var(--blue-mid);
}

.drop-zone .drop-icon { font-size: 40px; margin-bottom: 10px; }
.drop-zone p { font-size: 14px; color: var(--text-muted); }
.drop-zone strong { color: var(--blue-mid); }

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.form-label .req { color: #e53e3e; }

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--gray-border);
  border-radius: 6px;
  font-size: 14px;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: var(--white);
  font-family: inherit;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--blue-mid);
  box-shadow: 0 0 0 3px rgba(30,79,160,0.12);
}

.form-textarea { resize: vertical; min-height: 80px; }

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--gray-border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.btn {
  padding: 10px 24px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--blue-mid);
  color: var(--white);
}

.btn-primary:hover { background: var(--blue-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }

.btn-secondary {
  background: var(--white);
  color: var(--text-muted);
  border: 1px solid var(--gray-border);
}

.btn-secondary:hover { background: var(--gray-bg); }

/* ── PROGRESS ── */
.upload-progress {
  display: none;
  margin-top: 12px;
}

.progress-bar-wrap {
  background: var(--gray-border);
  border-radius: 20px;
  height: 8px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--blue-mid), var(--blue-accent));
  border-radius: 20px;
  transition: width 0.3s;
}

.progress-label { font-size: 12px; color: var(--text-muted); text-align: center; }

/* ── VIEW PAGE ── */
.view-layout {
  max-width: 1100px;
  margin: 28px auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
}

.doc-preview-wrap {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.doc-preview-header {
  background: var(--blue-dark);
  color: var(--white);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.doc-preview-header h3 { font-size: 16px; font-weight: 600; flex: 1; }

.preview-frame {
  width: 100%;
  height: 700px;
  border: none;
  display: block;
}

.no-preview {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}

.no-preview .np-icon { font-size: 60px; margin-bottom: 16px; }

.doc-info-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: sticky;
  top: 86px;
}

.doc-info-header {
  background: var(--blue-dark);
  color: var(--white);
  padding: 14px 18px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.doc-info-body { padding: 18px; }

.info-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-border);
}

.info-row:last-child { border: none; }
.info-label { font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--text-muted); }
.info-value { font-size: 14px; color: var(--text-main); }

.btn-download {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  background: var(--gold);
  color: var(--blue-dark);
  font-weight: 700;
  font-size: 15px;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
  border-radius: 0 0 var(--radius) var(--radius);
  margin-top: 16px;
}

.btn-download:hover { background: var(--gold-dark); }

.btn-delete-doc {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px;
  background: #fff5f5;
  color: #c53030;
  font-weight: 600;
  font-size: 13px;
  border: 1px solid #feb2b2;
  cursor: pointer;
  transition: all 0.15s;
  border-radius: 6px;
  margin-top: 8px;
}

.btn-delete-doc:hover { background: #fed7d7; }

/* ── FOOTER ── */
.footer {
  background: var(--blue-dark);
  color: rgba(255,255,255,0.7);
  padding: 24px;
  text-align: center;
  font-size: 13px;
  margin-top: auto;
}

.footer strong { color: var(--white); }

/* ── TOAST ── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--white);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  animation: toastIn 0.3s ease;
  max-width: 320px;
}

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

.toast.success { background: #276749; }
.toast.error   { background: #c53030; }
.toast.info    { background: var(--blue-mid); }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .main-container {
    grid-template-columns: 1fr;
  }
  .sidebar { position: static; }
  .view-layout { grid-template-columns: 1fr; }
  .doc-info-card { position: static; }
}

@media (max-width: 600px) {
  .header-top { height: auto; padding: 12px 16px; flex-wrap: wrap; gap: 10px; }
  .hero h2 { font-size: 20px; }
  .docs-grid { grid-template-columns: 1fr 1fr; }
  .main-container { padding: 16px; }
}

@media (max-width: 420px) {
  .docs-grid { grid-template-columns: 1fr; }
}

/* ── SKELETON LOADER ── */
.skeleton {
  background: linear-gradient(90deg, #e8ecf0 25%, #f4f6f9 50%, #e8ecf0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.selected-file-info {
  background: rgba(30,79,160,0.06);
  border: 1px solid rgba(30,79,160,0.2);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--blue-dark);
  margin-bottom: 16px;
  display: none;
  align-items: center;
  gap: 10px;
}

.selected-file-info.show { display: flex; }
