* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
  background: #f4f5f7;
  color: #1f2937;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Login page ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-box {
  background: #fff;
  padding: 40px 36px;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  width: 340px;
}

.login-box h1 {
  font-size: 20px;
  margin: 0 0 4px;
  color: #b91c1c;
}

.login-box p.subtitle {
  margin: 0 0 24px;
  color: #6b7280;
  font-size: 13px;
}

.login-box label {
  display: block;
  font-size: 13px;
  margin-bottom: 6px;
  color: #374151;
}

.login-box input {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 16px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
}

.login-box button {
  width: 100%;
  padding: 11px;
  background: #b91c1c;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.login-box button:hover {
  background: #991b1b;
}

.error-msg {
  color: #b91c1c;
  font-size: 13px;
  margin: -8px 0 16px;
  min-height: 16px;
}

/* ---------- Dashboard topbar ---------- */
.topbar {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: 14px 24px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

.topbar-left {
  display: flex;
  align-items: center;
}

.topbar-left .logo {
  height: 32px;
}

.topbar-title {
  text-align: center;
  font-size: 18px;
  margin: 0;
  color: #b91c1c;
  white-space: nowrap;
}

.topbar .actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-self: end;
}

.topbar button {
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
}

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

.topbar .username {
  font-size: 13px;
  color: #6b7280;
}

/* ---------- Main content ---------- */
.container {
  padding: 24px;
  max-width: 1100px;
  margin: 0 auto;
  flex: 1 0 auto;
  width: 100%;
}

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

.project-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 22px 20px;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  gap: 14px;
}

.project-card:hover {
  box-shadow: 0 8px 20px rgba(185, 28, 28, 0.1);
  transform: translateY(-2px);
  border-color: #fecaca;
}

.project-card .icon {
  font-size: 20px;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fef2f2;
  border-radius: 10px;
}

.project-card .name {
  font-weight: 600;
  font-size: 15px;
  color: #1f2937;
}

.empty-state, .error-state {
  text-align: center;
  color: #6b7280;
  padding: 60px 20px;
}

/* ---------- Responsive (mobile) ---------- */
@media (max-width: 640px) {
  .topbar {
    grid-template-columns: 1fr;
    row-gap: 10px;
    padding: 14px 16px;
  }

  .topbar-left {
    justify-content: center;
  }

  .topbar-title {
    font-size: 15px;
    white-space: normal;
    order: -1;
  }

  .topbar .actions {
    justify-self: center;
    flex-wrap: wrap;
    justify-content: center;
  }

  .container {
    padding: 16px;
  }

  .project-grid {
    grid-template-columns: 1fr;
  }

  .viewer-panel {
    margin: 0;
    border-radius: 0;
  }
}

/* ---------- Footer ---------- */
.app-footer {
  flex-shrink: 0;
  text-align: center;
  font-size: 12px;
  color: #9ca3af;
  padding: 16px 24px 24px;
}

.app-footer a {
  color: #b91c1c;
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}

/* ---------- PDF viewer modal ---------- */
.viewer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: stretch;
  justify-content: stretch;
  z-index: 50;
}

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

.viewer-panel {
  background: #fff;
  margin: 20px;
  border-radius: 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.viewer-header {
  padding: 12px 18px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.viewer-header h2 {
  font-size: 16px;
  margin: 0;
}

.viewer-header button {
  border: none;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
  color: #6b7280;
}

.viewer-body {
  flex: 1;
}

.viewer-body iframe {
  width: 100%;
  height: 100%;
  border: none;
}