* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', Arial, sans-serif;
  background: linear-gradient(135deg, #0f172a, #1e293b);
  color: #f1f5f9;
  min-height: 100vh;
}

.screen {
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* ============ GATE ============ */
#gate {
  display: flex;
  align-items: center;
  justify-content: center;
}

.card {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 48px 40px;
  text-align: center;
  width: 90%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.card h1 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 400;
  color: #94a3b8;
}

.card h2 {
  margin: 4px 0 20px;
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: #ffffff;
}

.subtitle {
  color: #94a3b8;
  margin-bottom: 24px;
  font-size: 0.9rem;
}

#loginForm {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#passwordInput, #downloadPasswordInput, #searchBox {
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 1rem;
  outline: none;
}

#passwordInput { text-align: center; }

#passwordInput:focus, #downloadPasswordInput:focus, #searchBox:focus {
  border-color: #38bdf8;
}

#loginForm button, .modal-actions button, #confirmDownload {
  padding: 12px;
  border-radius: 8px;
  border: none;
  background: #38bdf8;
  color: #0f172a;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
}

#loginForm button:hover { background: #0ea5e9; }

.error {
  margin-top: 14px;
  color: #f87171;
  font-size: 0.85rem;
  min-height: 1em;
}

/* ============ TOPBAR (shared) ============ */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: #0f172a;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  font-weight: 600;
  gap: 12px;
}

.topbar button {
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  background: #334155;
  color: #fff;
  cursor: pointer;
  font-size: 0.85rem;
  white-space: nowrap;
}

.topbar button:hover { background: #475569; }

#logoutBtnDash { background: #ef4444; }
#logoutBtnDash:hover { background: #dc2626; }

#downloadBtn { background: #22c55e; color: #052e14; }
#downloadBtn:hover { background: #16a34a; }

/* ============ DASHBOARD ============ */
.dashboard-screen { display: flex; flex-direction: column; }

.dashboard-body {
  padding: 20px;
  flex: 1;
  overflow-y: auto;
}

.dashboard-intro { margin-bottom: 20px; }

#searchBox { width: 100%; max-width: 400px; }

.category-block {
  margin-bottom: 24px;
}

.category-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #38bdf8;
  border-bottom: 1px solid rgba(255,255,255,0.15);
  padding-bottom: 8px;
  margin-bottom: 12px;
}

.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.file-card {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 16px;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
}

.file-card:hover {
  background: rgba(255,255,255,0.12);
  transform: translateY(-2px);
}

.file-card .icon { font-size: 1.6rem; margin-bottom: 8px; }
.file-card .title { font-size: 0.9rem; font-weight: 600; line-height: 1.3; }

.empty-note {
  color: #64748b;
  font-size: 0.85rem;
  font-style: italic;
}

/* ============ VIEWER ============ */
.viewer-screen { display: flex; flex-direction: column; }

#viewerTitle {
  flex: 1;
  text-align: center;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 10px;
  background: #111827;
  font-size: 0.85rem;
}

.viewer-controls button {
  padding: 6px 14px;
  border-radius: 6px;
  border: none;
  background: #334155;
  color: #fff;
  cursor: pointer;
}

.viewer-controls button:hover { background: #475569; }
.viewer-controls button:disabled { opacity: 0.4; cursor: not-allowed; }

.pdf-canvas-wrap {
  flex: 1;
  overflow: auto;
  display: flex;
  justify-content: center;
  padding: 20px;
  background: #1e293b;
  user-select: none;
}

#pdfCanvas {
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  max-width: 100%;
  background: #fff;
}

/* ============ MODAL DOWNLOAD ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-card {
  background: #1e293b;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 12px;
  padding: 28px;
  width: 90%;
  max-width: 340px;
  text-align: center;
}

.modal-card h3 { margin-top: 0; }
.modal-card p { color: #94a3b8; font-size: 0.85rem; }

#downloadPasswordInput { width: 100%; margin: 12px 0; text-align: center; }

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-actions button { flex: 1; }

#cancelDownload {
  background: #334155;
  color: #fff;
}
#cancelDownload:hover { background: #475569; }
